EtcPal  HEAD (unstable)
ETC Platform Abstraction Layer (EtcPal)
View other versions:
StrictLockPtr< T, LockType > Class Template Reference

Overview

template<typename T, typename LockType = Mutex>
class etcpal::StrictLockPtr< T, LockType >

An RAII handle holding a SynchronizedValue's lock and granting mutable access to the value.

Like ConstStrictLockPtr, but hands out mutable access. Normally obtained from SynchronizedValue. Move-only.

Note
StrictLockPtr implies the lock is held, but this fails to be true if moved.
Template Parameters
TThe type of the guarded value.
LockTypeThe type of lock guarding the value.
Inheritance diagram for StrictLockPtr< T, LockType >:
ConstStrictLockPtr< T, Mutex >

Public Member Functions

 StrictLockPtr (SynchronizedValue< T, LockType > &sync)
 Lock the given SynchronizedValue for mutable access. More...
 
 StrictLockPtr (SynchronizedValue< T, LockType > &sync, AdoptLockTag) noexcept
 Adopt the given SynchronizedValue's lock, which the calling thread must already hold.
 
 StrictLockPtr (UniqueLockPtr< T, LockType > &&other)
 Take over the lock held by other, which is left empty. More...
 
T & operator* () noexcept
 Get a mutable reference to the guarded value. Undefined behavior if this handle has been moved from.
 
T * operator-> () noexcept
 Access a member of the guarded value. Undefined behavior if this handle has been moved from.
 
- Public Member Functions inherited from ConstStrictLockPtr< T, Mutex >
 ConstStrictLockPtr (const SynchronizedValue< T, Mutex > &sync)
 Lock the given SynchronizedValue for read-only access. More...
 
 ConstStrictLockPtr (const SynchronizedValue< T, Mutex > &sync, AdoptLockTag) noexcept
 Adopt the given SynchronizedValue's lock, which the calling thread must already hold.
 
 ConstStrictLockPtr (ConstUniqueLockPtr< T, Mutex > &&other)
 Take over the lock held by other, which is left empty. More...
 
 ConstStrictLockPtr (const ConstStrictLockPtr &)=delete
 
 ConstStrictLockPtr (ConstStrictLockPtr &&other) noexcept
 Move ownership of the held lock from another handle, which is left empty.
 
ConstStrictLockPtroperator= (const ConstStrictLockPtr &)=delete
 
ConstStrictLockPtroperator= (ConstStrictLockPtr &&)=delete
 
 ~ConstStrictLockPtr () noexcept
 Release the lock.
 
const T & operator* () const noexcept
 Get a reference to the guarded value. Undefined behavior if this handle has been moved from.
 
const T * operator-> () const noexcept
 Access a member of the guarded value. Undefined behavior if this handle has been moved from.
 

Additional Inherited Members

- Protected Attributes inherited from ConstStrictLockPtr< T, Mutex >
const SynchronizedValue< T, Mutex > * sync_
 

Constructor & Destructor Documentation

◆ StrictLockPtr() [1/2]

StrictLockPtr ( SynchronizedValue< T, LockType > &  sync)
inlineexplicit

Lock the given SynchronizedValue for mutable access.

Exceptions
std::runtime_errorif lock could not be acquired.

◆ StrictLockPtr() [2/2]

StrictLockPtr ( UniqueLockPtr< T, LockType > &&  other)
inlineexplicit

Take over the lock held by other, which is left empty.

Exceptions
std::runtime_errorif other does not own the lock.

The documentation for this class was generated from the following file: