blocxx
BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT > Class Template Reference

This class is the implementation of the read/write lock. More...

#include <GenericRWLockImpl.hpp>

Classes

struct  LockerInfo
 

Public Member Functions

 GenericRWLockImpl ()
 
 ~GenericRWLockImpl ()
 
void acquireReadLock (const IdT id, const Timeout &timeout)
 
void acquireWriteLock (const IdT id, const Timeout &timeout)
 
void releaseReadLock (const IdT id)
 
void releaseWriteLock (const IdT id)
 

Private Types

typedef std::map< IdT, LockerInfo, CompareT > IdMap
 

Private Member Functions

 GenericRWLockImpl (const GenericRWLockImpl &)
 
GenericRWLockImploperator= (const GenericRWLockImpl &)
 

Private Attributes

Condition m_waiting_writers
 
bool m_canRead
 
Condition m_waiting_readers
 
NonRecursiveMutex m_guard
 
unsigned m_numReaders
 
unsigned m_numWriters
 
IdMap m_lockerInfo
 

Detailed Description

template<typename IdT, typename CompareT>
class BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >

This class is the implementation of the read/write lock.

It isn't thread specific and thus may be used for other types of locking, such as for transactions which may span threads, in which case the transaction would be the id. The read/write lock is recursive and also supports upgrading a read-lock to a write lock.

Definition at line 64 of file GenericRWLockImpl.hpp.

Member Typedef Documentation

◆ IdMap

template<typename IdT , typename CompareT >
std::map<IdT, LockerInfo, CompareT> BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::IdMap
private

Definition at line 120 of file GenericRWLockImpl.hpp.

Constructor & Destructor Documentation

◆ GenericRWLockImpl() [1/2]

template<typename IdT , typename CompareT >
BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::GenericRWLockImpl ( )

Definition at line 130 of file GenericRWLockImpl.hpp.

◆ ~GenericRWLockImpl()

template<typename IdT , typename CompareT >
BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::~GenericRWLockImpl ( )

Definition at line 138 of file GenericRWLockImpl.hpp.

◆ GenericRWLockImpl() [2/2]

template<typename IdT , typename CompareT >
BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::GenericRWLockImpl ( const GenericRWLockImpl< IdT, CompareT > & )
private

Member Function Documentation

◆ acquireReadLock()

◆ acquireWriteLock()

template<typename IdT , typename CompareT >
void BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::acquireWriteLock ( const IdT id,
const Timeout & timeout )
Exceptions
TimeoutExceptionif the lock isn't acquired within the timeout.
DeadlockExceptionif this call would upgrade a read lock to a write lock and another id is already waiting to upgrade. If this happens, the calling thread must release it's read lock in order for forward progress to be made.

Definition at line 211 of file GenericRWLockImpl.hpp.

References BLOCXX_NAMESPACE::TimeoutTimer::asAbsoluteTimeout(), BLOCXX_ASSERT, BLOCXX_THROW, BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::LockerInfo::isReader(), BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::LockerInfo::isWriter(), m_guard, BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::LockerInfo::readCount, and BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::LockerInfo::writeCount.

◆ operator=()

template<typename IdT , typename CompareT >
GenericRWLockImpl & BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::operator= ( const GenericRWLockImpl< IdT, CompareT > & )
private

◆ releaseReadLock()

◆ releaseWriteLock()

Member Data Documentation

◆ m_canRead

template<typename IdT , typename CompareT >
bool BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::m_canRead
private

Definition at line 97 of file GenericRWLockImpl.hpp.

◆ m_guard

template<typename IdT , typename CompareT >
NonRecursiveMutex BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::m_guard
private

Definition at line 100 of file GenericRWLockImpl.hpp.

◆ m_lockerInfo

template<typename IdT , typename CompareT >
IdMap BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::m_lockerInfo
private

Definition at line 121 of file GenericRWLockImpl.hpp.

◆ m_numReaders

template<typename IdT , typename CompareT >
unsigned BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::m_numReaders
private

Definition at line 101 of file GenericRWLockImpl.hpp.

◆ m_numWriters

template<typename IdT , typename CompareT >
unsigned BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::m_numWriters
private

Definition at line 102 of file GenericRWLockImpl.hpp.

◆ m_waiting_readers

template<typename IdT , typename CompareT >
Condition BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::m_waiting_readers
private

Definition at line 98 of file GenericRWLockImpl.hpp.

◆ m_waiting_writers

template<typename IdT , typename CompareT >
Condition BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::m_waiting_writers
private

Definition at line 95 of file GenericRWLockImpl.hpp.


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