Kea  1.9.9-git
isc::util::ReadWriteMutex Class Reference

Read-Write Mutex. More...

#include <readwrite_mutex.h>

+ Inheritance diagram for isc::util::ReadWriteMutex:

Public Member Functions

 ReadWriteMutex ()
 Constructor. More...
 
virtual ~ReadWriteMutex ()
 Destructor. More...
 
void readLock ()
 Lock read. More...
 
void readUnlock ()
 Unlock read. More...
 
void writeLock ()
 Lock write. More...
 
void writeUnlock ()
 Unlock write. More...
 

Static Public Attributes

static const unsigned MAX_READERS = ~WRITE_ENTERED
 The maximum number of readers (flag complement so 2^31 - 1). More...
 
static const unsigned WRITE_ENTERED
 Constants. More...
 

Detailed Description

Read-Write Mutex.

The code is based on Howard Hinnant's reference implementation for C++17 shared_mutex.

Definition at line 29 of file readwrite_mutex.h.

Constructor & Destructor Documentation

isc::util::ReadWriteMutex::ReadWriteMutex ( )
inline

Constructor.

Definition at line 42 of file readwrite_mutex.h.

virtual isc::util::ReadWriteMutex::~ReadWriteMutex ( )
inlinevirtual

Destructor.

Note
: do not check that state is 0 as there is nothing very useful to do in this case...

Definition at line 49 of file readwrite_mutex.h.

Member Function Documentation

void isc::util::ReadWriteMutex::readLock ( )
inline

Lock read.

Definition at line 74 of file readwrite_mutex.h.

Referenced by isc::util::ReadLockGuard::ReadLockGuard().

void isc::util::ReadWriteMutex::readUnlock ( )
inline

Unlock read.

Note
: do not check that there is a least one reader.

Definition at line 84 of file readwrite_mutex.h.

Referenced by isc::util::ReadLockGuard::~ReadLockGuard().

void isc::util::ReadWriteMutex::writeLock ( )
inline

Lock write.

Definition at line 54 of file readwrite_mutex.h.

References WRITE_ENTERED.

Referenced by isc::util::WriteLockGuard::WriteLockGuard().

void isc::util::ReadWriteMutex::writeUnlock ( )
inline

Unlock write.

Note
: do not check that WRITE_ENTERED was set.

Definition at line 66 of file readwrite_mutex.h.

Referenced by isc::util::WriteLockGuard::~WriteLockGuard().

Member Data Documentation

const unsigned isc::util::ReadWriteMutex::MAX_READERS = ~WRITE_ENTERED
static

The maximum number of readers (flag complement so 2^31 - 1).

Definition at line 39 of file readwrite_mutex.h.

const unsigned isc::util::ReadWriteMutex::WRITE_ENTERED
static
Initial value:
=
1U << (sizeof(unsigned) * CHAR_BIT - 1)

Constants.

The write entered flag (higher bit so 2^31).

Definition at line 35 of file readwrite_mutex.h.

Referenced by writeLock().


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