Samchon Framework for CPP  1.0.0
samchon::library::RWMutex Class Reference

rw_mutex More...

#include <RWMutex.hpp>

Public Member Functions

 RWMutex ()
 Default Constructor. More...
void readLock () const
 Lock on read. More...
void readUnlock () const
 Unlock of read. More...
void writeLock ()
 Lock on writing. More...
void writeUnlock ()
 Unlock on writing. More...

Detailed Description


A mutex divided into reading and writing.

Class Diagram

Of course, rw_mutex is already defined in linux C. But it is dependent on the linux OS, so that cannot be compiled in Window having the rw_mutex. There's not a class like rw_mutex in STL yet. It's the reason why RWMutex is provided.

As that reason, if STL supports the rw_mutex in near future, the RWMutex can be deprecated.

Library - Critical Section

Jeongho Nam

Definition at line 29 of file RWMutex.hpp.

Constructor & Destructor Documentation

samchon::library::RWMutex::RWMutex ( )

Default Constructor.

Definition at line 49 of file RWMutex.hpp.

Member Function Documentation

void samchon::library::RWMutex::readLock ( ) const

Lock on read.

Increases a reading count.

When write_lock is on a progress, wait until write_unlock to be called.

  • Reading can be done by multiple sections.
  • Reading can't be done when writing.
You've to call read_unlock when the reading work is terminated.

Definition at line 67 of file RWMutex.hpp.

Referenced by samchon::library::UniqueReadLock::lock(), samchon::library::SharedReadLock::lock(), and samchon::library::SharedReadLock::SharedReadLock().

Here is the caller graph for this function:

void samchon::library::RWMutex::readUnlock ( ) const

Unlock of read.

Decreases a reading count.

When write_lock had done after read_lock, it continues by read_unlock if the reading count was 1 (read_unlock makes the count to be zero).

Definition at line 90 of file RWMutex.hpp.

Referenced by samchon::library::UniqueReadLock::unlock(), samchon::library::SharedReadLock::unlock(), samchon::library::SharedReadLock::~SharedReadLock(), and samchon::library::UniqueReadLock::~UniqueReadLock().

Here is the caller graph for this function:

void samchon::library::RWMutex::writeLock ( )

Lock on writing.

Changes writing flag to true.

If another write_lock or read_lock is on a progress, wait until them to be unlocked.

  • Writing can be done by only a section at once.
  • Writing can't be done when reading.
You've to call write_unlock when writing work was terminated.

Definition at line 117 of file RWMutex.hpp.

Referenced by samchon::library::UniqueWriteLock::lock(), and samchon::library::SharedWriteLock::lock().

Here is the caller graph for this function:

void samchon::library::RWMutex::writeUnlock ( )

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