70 : m_mutex{
nullptr}, m_owns{
false} {}
78 : m_mutex{&
mutex}, m_owns{false} {
89 : m_mutex{&
mutex}, m_owns{
false} {}
97 : m_mutex{&
mutex}, m_owns{mutex.try_lock()} {}
105 : m_mutex{&
mutex}, m_owns{
true} {}
114 : m_mutex{other.m_mutex}, m_owns{other.m_owns} {
115 other.m_mutex =
nullptr;
116 other.m_owns =
false;
135 if (
this != &other) {
138 m_mutex = other.m_mutex;
139 m_owns = other.m_owns;
140 other.m_mutex =
nullptr;
141 other.m_owns =
false;
161 if (m_mutex ==
nullptr)
163 m_owns = m_mutex->try_lock();
181 Mutex* released = m_mutex;
207 explicit operator bool() const noexcept {
216 Mutex* held = m_mutex;
217 const bool owns = m_owns;
218 m_mutex = other.m_mutex;
219 m_owns = other.m_owns;
220 other.m_mutex = held;
230 void Abandon() noexcept {
237 void Claim() noexcept {
Wakes threads waiting on a Mutex.
Definition condition_variable.hxx:64
Non-recursive mutex.
Definition mutex.hxx:62
Owns at most one Mutex.
Definition unique_lock.hxx:64
UniqueLock() noexcept
Empty lock.
Definition unique_lock.hxx:69
UniqueLock & operator=(const UniqueLock &)=delete
UniqueLock(UniqueLock &&other) noexcept
Take a lock.
Definition unique_lock.hxx:113
UniqueLock & operator=(UniqueLock &&other) noexcept
Take a lock.
Definition unique_lock.hxx:134
Mutex * release() noexcept
Drop the association without unlocking.
Definition unique_lock.hxx:180
bool owns_lock() const noexcept
Whether this lock owns the mutex.
Definition unique_lock.hxx:199
UniqueLock(Mutex &mutex, TryToLock tag) noexcept
Try to lock mutex.
Definition unique_lock.hxx:96
UniqueLock(Mutex &mutex, AdoptLock tag) noexcept
Assume the calling thread already owns mutex.
Definition unique_lock.hxx:104
void lock()
Acquire the associated mutex.
Definition unique_lock.hxx:151
Mutex * mutex() const noexcept
Associated mutex.
Definition unique_lock.hxx:191
bool try_lock() noexcept
Try to acquire the associated mutex.
Definition unique_lock.hxx:160
friend class ConditionVariable
Definition unique_lock.hxx:225
UniqueLock(Mutex &mutex, DeferLock tag) noexcept
Associate mutex without locking it.
Definition unique_lock.hxx:88
void swap(UniqueLock &other) noexcept
Exchange two locks.
Definition unique_lock.hxx:215
void unlock() noexcept
Release ownership.
Definition unique_lock.hxx:171
~UniqueLock() noexcept
Unlock if this lock owns the mutex.
Definition unique_lock.hxx:122
UniqueLock(Mutex &mutex)
Lock mutex.
Definition unique_lock.hxx:77
UniqueLock(const UniqueLock &)=delete
Owned values that cross a DLL without the caller's CRT.
void swap(Binary &left, Binary &right) noexcept
Exchange two sequences.
Definition binary.hxx:760
Root namespace of the StormByte suite.
The calling thread already owns the mutex.
Definition memory_order.hxx:104
Do not lock the mutex in the UniqueLock constructor.
Definition memory_order.hxx:82
Try to lock the mutex in the UniqueLock constructor.
Definition memory_order.hxx:93
#define STORMBYTE_PUBLIC_TYPE
Definition visibility.h:57