blocxx
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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 94 of file GenericRWLockImpl.hpp.

Member Typedef Documentation

◆ IdMap

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

Definition at line 150 of file GenericRWLockImpl.hpp.

Constructor & Destructor Documentation

◆ GenericRWLockImpl() [1/2]

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

◆ ~GenericRWLockImpl()

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

Definition at line 168 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()

template<typename IdT , typename CompareT >
void BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::acquireReadLock ( const IdT  id,
const Timeout timeout 
)
Exceptions
TimeoutExceptionif the lock isn't acquired within the timeout.

Definition at line 174 of file GenericRWLockImpl.hpp.

◆ 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 241 of file GenericRWLockImpl.hpp.

References BLOCXX_NAMESPACE::TimeoutTimer::asAbsoluteTimeout(), BLOCXX_ASSERT, and BLOCXX_THROW.

◆ operator=()

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

◆ releaseReadLock()

template<typename IdT , typename CompareT >
void BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::releaseReadLock ( const IdT  id)
Exceptions
GenericRWLockImplExceptionif a read lock hasn't been acquired.

Definition at line 211 of file GenericRWLockImpl.hpp.

References BLOCXX_ASSERT, and m_guard.

◆ releaseWriteLock()

template<typename IdT , typename CompareT >
void BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::releaseWriteLock ( const IdT  id)
Exceptions
GenericRWLockImplExceptionif a write lock hasn't been acquired.

Definition at line 342 of file GenericRWLockImpl.hpp.

Member Data Documentation

◆ m_canRead

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

Definition at line 127 of file GenericRWLockImpl.hpp.

◆ m_guard

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

Definition at line 130 of file GenericRWLockImpl.hpp.

◆ m_lockerInfo

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

Definition at line 151 of file GenericRWLockImpl.hpp.

◆ m_numReaders

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

Definition at line 131 of file GenericRWLockImpl.hpp.

◆ m_numWriters

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

Definition at line 132 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 128 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 125 of file GenericRWLockImpl.hpp.


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