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

RAII guard for read-only access to the synchronized value. More...

#include <concurrency_utils.H>

Collaboration diagram for Aleph::Synchronized< T, Mutex >::ConstLockedPtr:
[legend]

Public Member Functions

 ConstLockedPtr (Mutex &mutex, const T &value)
 Construct a guard and acquire the 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::unique_lock< Mutexlock_
 
const Tptr_
 

Detailed Description

template<typename T, typename Mutex = std::mutex>
class Aleph::Synchronized< T, Mutex >::ConstLockedPtr

RAII guard for read-only access to the synchronized value.

Note
Thread-safe to use only while the guard object remains alive on the thread that acquired it. The destructor releases the lock.

Definition at line 747 of file concurrency_utils.H.

Constructor & Destructor Documentation

◆ ConstLockedPtr()

template<typename T , typename Mutex = std::mutex>
Aleph::Synchronized< T, Mutex >::ConstLockedPtr::ConstLockedPtr ( Mutex mutex,
const T value 
)
inline

Construct a guard and acquire the lock.

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

Definition at line 758 of file concurrency_utils.H.

Member Function Documentation

◆ get()

template<typename T , typename Mutex = std::mutex>
const T & Aleph::Synchronized< T, Mutex >::ConstLockedPtr::get ( ) const
inlinenoexcept

Access the protected value.

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

Definition at line 765 of file concurrency_utils.H.

References Aleph::Synchronized< T, Mutex >::ConstLockedPtr::ptr_.

◆ operator*()

template<typename T , typename Mutex = std::mutex>
const T & Aleph::Synchronized< T, Mutex >::ConstLockedPtr::operator* ( ) const
inlinenoexcept

Access the protected value.

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

Definition at line 775 of file concurrency_utils.H.

References Aleph::Synchronized< T, Mutex >::ConstLockedPtr::ptr_.

◆ operator->()

template<typename T , typename Mutex = std::mutex>
const T * Aleph::Synchronized< T, Mutex >::ConstLockedPtr::operator-> ( ) const
inlinenoexcept

Access members of the protected value.

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

Definition at line 770 of file concurrency_utils.H.

References Aleph::Synchronized< T, Mutex >::ConstLockedPtr::ptr_.

Member Data Documentation

◆ lock_

template<typename T , typename Mutex = std::mutex>
std::unique_lock<Mutex> Aleph::Synchronized< T, Mutex >::ConstLockedPtr::lock_
private

Definition at line 749 of file concurrency_utils.H.

◆ ptr_


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