Kùzu C++ API
Loading...
Searching...
No Matches
uniq_lock.h
Go to the documentation of this file.
1#pragma once
2
3#include <mutex>
4
5namespace kuzu {
6namespace common {
7
8struct UniqLock {
10 explicit UniqLock(std::mutex& mtx) : lck{mtx} {}
11
12 UniqLock(const UniqLock&) = delete;
13 UniqLock& operator=(const UniqLock&) = delete;
14
15 UniqLock(UniqLock&& other) noexcept { std::swap(lck, other.lck); }
16 UniqLock& operator=(UniqLock&& other) noexcept {
17 std::swap(lck, other.lck);
18 return *this;
19 }
20 bool isLocked() const { return lck.owns_lock(); }
21
22private:
23 std::unique_lock<std::mutex> lck;
24};
25
26} // namespace common
27} // namespace kuzu
Definition alter_type.h:5
Definition uniq_lock.h:8
UniqLock(const UniqLock &)=delete
UniqLock()
Definition uniq_lock.h:9
UniqLock(std::mutex &mtx)
Definition uniq_lock.h:10
bool isLocked() const
Definition uniq_lock.h:20
UniqLock(UniqLock &&other) noexcept
Definition uniq_lock.h:15
UniqLock & operator=(const UniqLock &)=delete
UniqLock & operator=(UniqLock &&other) noexcept
Definition uniq_lock.h:16