Owns at most one shared hold of a SharedMutex.
More...
#include <StormByte/safe/shared_lock.hxx>
Owns at most one shared hold of a SharedMutex.
Header-only. The object is a pointer and an ownership flag. It does not contain a standard lock. lock and unlock take and drop the shared hold, so ConditionVariableAny can wait on it.
◆ SharedLock() [1/7]
| StormByte::Safe::SharedLock::SharedLock |
( |
| ) |
|
|
inlinenoexcept |
Empty lock.
Owns nothing.
◆ SharedLock() [2/7]
| StormByte::Safe::SharedLock::SharedLock |
( |
SharedMutex & | mutex | ) |
|
|
inlineexplicit |
Take a shared hold of mutex.
- Parameters
-
- Exceptions
-
◆ SharedLock() [3/7]
Associate mutex without locking it.
- Parameters
-
| mutex | Shared mutex to lock later. |
| tag | Deferred-lock tag. |
◆ SharedLock() [4/7]
Try to take a shared hold of mutex.
- Parameters
-
| mutex | Shared mutex to try. |
| tag | Try-lock tag. |
◆ SharedLock() [5/7]
Assume the calling thread already holds mutex shared.
- Parameters
-
| mutex | Shared mutex already held by this thread. |
| tag | Adopt tag. |
◆ SharedLock() [6/7]
| StormByte::Safe::SharedLock::SharedLock |
( |
const SharedLock & | | ) |
|
|
delete |
◆ SharedLock() [7/7]
| StormByte::Safe::SharedLock::SharedLock |
( |
SharedLock && | other | ) |
|
|
inlinenoexcept |
Take a lock.
other owns nothing afterwards.
- Parameters
-
◆ ~SharedLock()
| StormByte::Safe::SharedLock::~SharedLock |
( |
| ) |
|
|
inlinenoexcept |
Drop the shared hold if this lock owns it.
◆ lock()
| void StormByte::Safe::SharedLock::lock |
( |
| ) |
|
|
inline |
Take a shared hold of the associated mutex.
- Precondition
- A mutex is associated and this lock does not own it.
- Exceptions
-
◆ mutex()
| SharedMutex * StormByte::Safe::SharedLock::mutex |
( |
| ) |
const |
|
inlinenoexcept |
Associated mutex.
- Returns
- The mutex, or null.
◆ operator bool()
| StormByte::Safe::SharedLock::operator bool |
( |
| ) |
const |
|
inlineexplicitnoexcept |
Whether this lock owns the shared hold.
- Returns
- Ownership flag.
◆ operator=() [1/2]
◆ operator=() [2/2]
Take a lock.
Drops the previous shared hold when owned.
- Parameters
-
| other | Source. Left not owning. |
- Returns
- This lock.
◆ owns_lock()
| bool StormByte::Safe::SharedLock::owns_lock |
( |
| ) |
const |
|
inlinenoexcept |
Whether this lock owns the shared hold.
- Returns
- Ownership flag.
◆ release()
Drop the association without unlocking.
- Returns
- The previous mutex, or null.
◆ swap()
| void StormByte::Safe::SharedLock::swap |
( |
SharedLock & | other | ) |
|
|
inlinenoexcept |
Exchange two locks.
- Parameters
-
◆ try_lock()
| bool StormByte::Safe::SharedLock::try_lock |
( |
| ) |
|
|
inlinenoexcept |
Try to take a shared hold of the associated mutex.
- Returns
- Whether this lock now owns it. False when no mutex is associated.
◆ unlock()
| void StormByte::Safe::SharedLock::unlock |
( |
| ) |
|
|
inlinenoexcept |
Drop the shared hold.
- Precondition
- This lock owns the shared hold.
The documentation for this class was generated from the following file: