Kea 2.7.6
isc::util::ReadWriteMutex Class Reference

Read-Write Mutex. More...

#include <readwrite_mutex.h>

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

Public Member Functions

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

Static Public Attributes

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

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

◆ ReadWriteMutex()

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

Constructor.

Definition at line 42 of file readwrite_mutex.h.

◆ ~ReadWriteMutex()

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

◆ readLock()

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

Lock read.

Definition at line 74 of file readwrite_mutex.h.

References MAX_READERS.

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

◆ readUnlock()

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.

References MAX_READERS.

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

◆ writeLock()

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().

◆ writeUnlock()

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

◆ MAX_READERS

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.

Referenced by readLock(), and readUnlock().

◆ WRITE_ENTERED

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: