template<typename T, typename LockType>
class etcpal::UniqueLockPtr< T, LockType >
An RAII handle for mutable access whose lock may or may not be held.
Like ConstUniqueLockPtr, but hands out mutable access. Returned by SynchronizedValue::TryToSynchronize() and the *Synchronize() factories, or constructed directly. Move-only.
- Template Parameters
-
| T | The type of the guarded value. |
| LockType | The type of lock guarding the value. |
|
| | UniqueLockPtr (SynchronizedValue< T, LockType > &sync) |
| | Lock the given SynchronizedValue for mutable access, blocking until the lock is acquired. More...
|
| |
|
| UniqueLockPtr (SynchronizedValue< T, LockType > &sync, AdoptLockTag) noexcept |
| | Adopt the given SynchronizedValue's lock, which the calling thread must already hold.
|
| |
|
| UniqueLockPtr (SynchronizedValue< T, LockType > &sync, DeferLockTag) noexcept |
| | Reference the given SynchronizedValue without acquiring the lock.
|
| |
| | UniqueLockPtr (SynchronizedValue< T, LockType > &sync, TryToLockTag, int timeout_ms=0) noexcept |
| | Try to lock the given SynchronizedValue, waiting up to timeout_ms; check OwnsLock() for the result. More...
|
| |
| T & | operator* () |
| | Get a mutable reference to the guarded value. More...
|
| |
| T * | operator-> () |
| | Access a member of the guarded value. More...
|
| |
| | ConstUniqueLockPtr (const SynchronizedValue< T, LockType > &sync) |
| | Lock the given SynchronizedValue for read-only access, blocking until the lock is acquired. More...
|
| |
|
| ConstUniqueLockPtr (const SynchronizedValue< T, LockType > &sync, AdoptLockTag) noexcept |
| | Adopt the given SynchronizedValue's lock, which the calling thread must already hold.
|
| |
|
| ConstUniqueLockPtr (const SynchronizedValue< T, LockType > &sync, DeferLockTag) noexcept |
| | Reference the given SynchronizedValue without acquiring the lock.
|
| |
| | ConstUniqueLockPtr (const SynchronizedValue< T, LockType > &sync, TryToLockTag, int timeout_ms=0) noexcept |
| | Try to lock the given SynchronizedValue, waiting up to timeout_ms; check OwnsLock() for the result. More...
|
| |
|
| ConstUniqueLockPtr (const ConstUniqueLockPtr &)=delete |
| |
|
ConstUniqueLockPtr & | operator= (const ConstUniqueLockPtr &)=delete |
| |
|
ConstUniqueLockPtr & | operator= (ConstUniqueLockPtr &&)=delete |
| |
|
| ConstUniqueLockPtr (ConstUniqueLockPtr &&other) noexcept |
| | Move ownership from another handle, which is left empty.
|
| |
|
| ~ConstUniqueLockPtr () noexcept |
| | Release the lock if owned.
|
| |
|
| operator bool () const noexcept |
| | Whether this handle currently owns the lock.
|
| |
|
bool | OwnsLock () const noexcept |
| | Whether this handle currently owns the lock.
|
| |
|
void | Unlock () noexcept |
| | Release the lock early, if owned. Does nothing otherwise.
|
| |
| void | Lock () |
| | Acquire the lock, blocking until it is available. More...
|
| |
| bool | TryLock (int timeout_ms=0) |
| | Try to acquire the lock, waiting up to timeout_ms. More...
|
| |
|
void | Release () noexcept |
| | Disassociate from the lock without unlocking it; the caller becomes responsible for the lock.
|
| |
| const T & | operator* () const |
| | Get a reference to the guarded value. More...
|
| |
| const T * | operator-> () const |
| | Access a member of the guarded value. More...
|
| |