Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr Class Reference

RAII guard for exclusive (write) access. More...

#include <concurrency_utils.H>

Collaboration diagram for Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr:
[legend]

Public Member Functions

 WriteLockedPtr (SharedMutex &mutex, T &value)
 Construct a guard and acquire an exclusive lock.
 
Tget () noexcept
 Access the protected value.
 
Toperator-> () noexcept
 Access members of the protected value.
 
Toperator* () noexcept
 Access the protected value.
 

Private Attributes

std::unique_lock< SharedMutexlock_
 
Tptr_
 

Detailed Description

template<typename T, typename SharedMutex = std::shared_mutex>
class Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr

RAII guard for exclusive (write) access.

Note
The guard holds an exclusive lock until destruction.

Definition at line 945 of file concurrency_utils.H.

Constructor & Destructor Documentation

◆ WriteLockedPtr()

template<typename T , typename SharedMutex = std::shared_mutex>
Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr::WriteLockedPtr ( SharedMutex mutex,
T value 
)
inline

Construct a guard and acquire an exclusive lock.

Parameters
mutexShared mutex protecting the value.
valueProtected object to expose through the guard.
Exceptions
Anyexception thrown while locking mutex.

Definition at line 956 of file concurrency_utils.H.

Member Function Documentation

◆ get()

template<typename T , typename SharedMutex = std::shared_mutex>
T & Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr::get ( )
inlinenoexcept

Access the protected value.

Returns
A mutable reference to the protected object.
Exceptions
Nothing.

Definition at line 963 of file concurrency_utils.H.

References Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr::ptr_.

◆ operator*()

template<typename T , typename SharedMutex = std::shared_mutex>
T & Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr::operator* ( )
inlinenoexcept

Access the protected value.

Returns
A mutable reference to the protected object.
Exceptions
Nothing.

Definition at line 973 of file concurrency_utils.H.

References Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr::ptr_.

◆ operator->()

template<typename T , typename SharedMutex = std::shared_mutex>
T * Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr::operator-> ( )
inlinenoexcept

Access members of the protected value.

Returns
A mutable pointer to the protected object.
Exceptions
Nothing.

Definition at line 968 of file concurrency_utils.H.

References Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr::ptr_.

Member Data Documentation

◆ lock_

template<typename T , typename SharedMutex = std::shared_mutex>
std::unique_lock<SharedMutex> Aleph::RwSynchronized< T, SharedMutex >::WriteLockedPtr::lock_
private

Definition at line 947 of file concurrency_utils.H.

◆ ptr_


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