Owns at most one Mutex.
More...
#include <StormByte/safe/unique_lock.hxx>
Owns at most one Mutex.
The wait primitive drops and retakes it.
Header-only. The object is a pointer and an ownership flag. It does not contain a standard lock.
◆ UniqueLock() [1/7]
| StormByte::Safe::UniqueLock::UniqueLock |
( |
| ) |
|
|
inlinenoexcept |
Empty lock.
Owns nothing.
◆ UniqueLock() [2/7]
| StormByte::Safe::UniqueLock::UniqueLock |
( |
Mutex & | mutex | ) |
|
|
inlineexplicit |
Lock mutex.
- Parameters
-
- Exceptions
-
◆ UniqueLock() [3/7]
| StormByte::Safe::UniqueLock::UniqueLock |
( |
Mutex & | mutex, |
|
|
DeferLock | tag ) |
|
inlinenoexcept |
Associate mutex without locking it.
- Parameters
-
| mutex | Mutex to lock later. |
| tag | Deferred-lock tag. |
◆ UniqueLock() [4/7]
| StormByte::Safe::UniqueLock::UniqueLock |
( |
Mutex & | mutex, |
|
|
TryToLock | tag ) |
|
inlinenoexcept |
Try to lock mutex.
- Parameters
-
| mutex | Mutex to try. |
| tag | Try-lock tag. |
◆ UniqueLock() [5/7]
| StormByte::Safe::UniqueLock::UniqueLock |
( |
Mutex & | mutex, |
|
|
AdoptLock | tag ) |
|
inlinenoexcept |
Assume the calling thread already owns mutex.
- Parameters
-
| mutex | Mutex already owned by this thread. |
| tag | Adopt tag. |
◆ UniqueLock() [6/7]
| StormByte::Safe::UniqueLock::UniqueLock |
( |
const UniqueLock & | | ) |
|
|
delete |
◆ UniqueLock() [7/7]
| StormByte::Safe::UniqueLock::UniqueLock |
( |
UniqueLock && | other | ) |
|
|
inlinenoexcept |
Take a lock.
other owns nothing afterwards.
- Parameters
-
◆ ~UniqueLock()
| StormByte::Safe::UniqueLock::~UniqueLock |
( |
| ) |
|
|
inlinenoexcept |
Unlock if this lock owns the mutex.
◆ lock()
| void StormByte::Safe::UniqueLock::lock |
( |
| ) |
|
|
inline |
Acquire the associated mutex.
- Precondition
- A mutex is associated and this lock does not own it.
- Exceptions
-
◆ mutex()
| Mutex * StormByte::Safe::UniqueLock::mutex |
( |
| ) |
const |
|
inlinenoexcept |
Associated mutex.
- Returns
- The mutex, or null.
◆ operator bool()
| StormByte::Safe::UniqueLock::operator bool |
( |
| ) |
const |
|
inlineexplicitnoexcept |
Whether this lock owns the mutex.
- Returns
- Ownership flag.
◆ operator=() [1/2]
◆ operator=() [2/2]
Take a lock.
Unlocks the previous mutex when owned.
- Parameters
-
| other | Source. Left not owning. |
- Returns
- This lock.
◆ owns_lock()
| bool StormByte::Safe::UniqueLock::owns_lock |
( |
| ) |
const |
|
inlinenoexcept |
Whether this lock owns the mutex.
- Returns
- Ownership flag.
◆ release()
| Mutex * StormByte::Safe::UniqueLock::release |
( |
| ) |
|
|
inlinenoexcept |
Drop the association without unlocking.
- Returns
- The previous mutex, or null.
◆ swap()
| void StormByte::Safe::UniqueLock::swap |
( |
UniqueLock & | other | ) |
|
|
inlinenoexcept |
Exchange two locks.
- Parameters
-
◆ try_lock()
| bool StormByte::Safe::UniqueLock::try_lock |
( |
| ) |
|
|
inlinenoexcept |
Try to acquire the associated mutex.
- Returns
- Whether this lock now owns it. False when no mutex is associated.
◆ unlock()
| void StormByte::Safe::UniqueLock::unlock |
( |
| ) |
|
|
inlinenoexcept |
Release ownership.
- Precondition
- This lock owns the mutex.
◆ ConditionVariable
| friend class ConditionVariable |
|
friend |
The documentation for this class was generated from the following file: