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, CompareTIdMap
 

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

Definition at line 120 of file GenericRWLockImpl.hpp.

Constructor & Destructor Documentation

◆ GenericRWLockImpl() [1/2]

Definition at line 130 of file GenericRWLockImpl.hpp.

◆ ~GenericRWLockImpl()

Definition at line 138 of file GenericRWLockImpl.hpp.

◆ GenericRWLockImpl() [2/2]

Member Function Documentation

◆ acquireReadLock()

template<typename IdT , typename CompareT >
void BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::acquireReadLock ( const IdT id,
const Timeout & timeout )

◆ 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_ASSERT, BLOCXX_THROW, m_guard, BLOCXX_NAMESPACE::operator==(), and BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::LockerInfo::readCount.

◆ operator=()

◆ releaseReadLock()

Exceptions
GenericRWLockImplExceptionif a read lock hasn't been acquired.

Definition at line 181 of file GenericRWLockImpl.hpp.

References BLOCXX_THROW, m_guard, and BLOCXX_NAMESPACE::operator==().

◆ releaseWriteLock()

Exceptions
GenericRWLockImplExceptionif a write lock hasn't been acquired.

Definition at line 312 of file GenericRWLockImpl.hpp.

References BLOCXX_ASSERT, BLOCXX_THROW, m_guard, and BLOCXX_NAMESPACE::operator==().

Member Data Documentation

◆ m_canRead

Definition at line 97 of file GenericRWLockImpl.hpp.

◆ m_guard

Definition at line 100 of file GenericRWLockImpl.hpp.

◆ m_lockerInfo

Definition at line 121 of file GenericRWLockImpl.hpp.

◆ m_numReaders

Definition at line 101 of file GenericRWLockImpl.hpp.

◆ m_numWriters

Definition at line 102 of file GenericRWLockImpl.hpp.

◆ m_waiting_readers

Definition at line 98 of file GenericRWLockImpl.hpp.

◆ m_waiting_writers

Definition at line 95 of file GenericRWLockImpl.hpp.


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