68 : m_mutex{
nullptr}, m_owns{
false} {}
76 : m_mutex{&
mutex}, m_owns{false} {
87 : m_mutex{&
mutex}, m_owns{
false} {
97 : m_mutex{&
mutex}, m_owns{mutex.try_lock_shared()} {
107 : m_mutex{&
mutex}, m_owns{
true} {
118 : m_mutex{other.m_mutex}, m_owns{other.m_owns} {
119 other.m_mutex =
nullptr;
120 other.m_owns =
false;
128 m_mutex->unlock_shared();
139 if (
this != &other) {
141 m_mutex->unlock_shared();
142 m_mutex = other.m_mutex;
143 m_owns = other.m_owns;
144 other.m_mutex =
nullptr;
145 other.m_owns =
false;
156 m_mutex->lock_shared();
165 if (m_mutex ==
nullptr)
167 m_owns = m_mutex->try_lock_shared();
176 m_mutex->unlock_shared();
211 explicit operator bool() const noexcept {
221 const bool owns = m_owns;
222 m_mutex = other.m_mutex;
223 m_owns = other.m_owns;
224 other.m_mutex = held;
Owns at most one shared hold of a SharedMutex.
Definition shared_lock.hxx:62
void unlock() noexcept
Drop the shared hold.
Definition shared_lock.hxx:175
bool try_lock() noexcept
Try to take a shared hold of the associated mutex.
Definition shared_lock.hxx:164
SharedLock(SharedMutex &mutex, DeferLock tag) noexcept
Associate mutex without locking it.
Definition shared_lock.hxx:86
SharedLock() noexcept
Empty lock.
Definition shared_lock.hxx:67
SharedLock(SharedMutex &mutex, TryToLock tag) noexcept
Try to take a shared hold of mutex.
Definition shared_lock.hxx:96
bool owns_lock() const noexcept
Whether this lock owns the shared hold.
Definition shared_lock.hxx:203
SharedLock(SharedMutex &mutex)
Take a shared hold of mutex.
Definition shared_lock.hxx:75
SharedLock(SharedMutex &mutex, AdoptLock tag) noexcept
Assume the calling thread already holds mutex shared.
Definition shared_lock.hxx:106
void lock()
Take a shared hold of the associated mutex.
Definition shared_lock.hxx:155
SharedMutex * mutex() const noexcept
Associated mutex.
Definition shared_lock.hxx:195
~SharedLock() noexcept
Drop the shared hold if this lock owns it.
Definition shared_lock.hxx:126
SharedMutex * release() noexcept
Drop the association without unlocking.
Definition shared_lock.hxx:184
SharedLock(SharedLock &&other) noexcept
Take a lock.
Definition shared_lock.hxx:117
SharedLock & operator=(const SharedLock &)=delete
SharedLock & operator=(SharedLock &&other) noexcept
Take a lock.
Definition shared_lock.hxx:138
SharedLock(const SharedLock &)=delete
void swap(SharedLock &other) noexcept
Exchange two locks.
Definition shared_lock.hxx:219
Non-recursive shared mutex.
Definition shared_mutex.hxx:60
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