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

RAII guard for shared (read-only) access. More...

#include <concurrency_utils.H>

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

Public Member Functions

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

Private Attributes

std::shared_lock< SharedMutexlock_
 
const Tptr_
 

Detailed Description

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

RAII guard for shared (read-only) access.

Note
The guard holds a shared lock until destruction.

Definition at line 911 of file concurrency_utils.H.

Constructor & Destructor Documentation

◆ ReadLockedPtr()

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

Construct a guard and acquire a shared lock.

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

Definition at line 922 of file concurrency_utils.H.

Member Function Documentation

◆ get()

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

Access the protected value.

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

Definition at line 929 of file concurrency_utils.H.

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

◆ operator*()

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

Access the protected value.

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

Definition at line 939 of file concurrency_utils.H.

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

◆ operator->()

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

Access members of the protected value.

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

Definition at line 934 of file concurrency_utils.H.

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

Member Data Documentation

◆ lock_

template<typename T , typename SharedMutex = std::shared_mutex>
std::shared_lock<SharedMutex> Aleph::RwSynchronized< T, SharedMutex >::ReadLockedPtr::lock_
private

Definition at line 913 of file concurrency_utils.H.

◆ ptr_


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