class RWMutex : private NoCopy
This class mediates reader-writer sharing of global data. Only single thread can EnterWrite, but any number of threads can EnterRead. RWMutex is NOT reentrant (same thread can Enter the Mutex multiple times).
void EnterWrite()
Blocks until all threads Leave the RWMutex, then enters it and blocks any threads to enter the RWMutex until invoking LeaveWrite().
void LeaveWrite()
Leaves the RWMutex.
void EnterRead()
Enter in read mode. More than single thread can enter the RWMutex in read mode. Blocks any threads attempting EnterWrite, until all reader threads leave using LeaveRead.
void LeaveRead()
Leave the read mode.
class StaticRWMutex
Variant of RWMutex that can be used as static or global variable without the need of initialization - it has no constructor and correctly performs the first initialization when any of methods is called. That avoids problems with initialization order or multithreaded initialization issues.
RWMutex& Get()
operator RWMutex&()
Returns the instance of RWMutex.
void EnterRead()
void LeaveRead()
void EnterWrite()
void LeaveWrite()
Calls respective RWMutex methods.
class ReadLock
This nested class automates calls to Mutex::EnterRead / Mutex::LeaveRead for block of code using C++ constructor / destructor rules. Using operator StaticRWMutex::RWMutex, it can be used with StaticRWMutex as well.
Constructor / Destructor detail
|
|
ReadLock(RWMutex& s)
Calls s.EnterRead().
~ReadLock()
Calls s.LeaveRead() where s is the constructor parameter.
class WriteLock
This nested class automates calls to Mutex::EnterWrite / Mutex::LeaveLeave for block of code using C++ constructor / destructor rules. Using operator StaticRWMutex::RWMutex, it can be used with StaticRWMutex as well.
Constructor / Destructor detail
|
|
WriteLock(RWMutex& s)
Calls s.EnterWrite().
~WriteLock()
Calls s.LeaveWrite() where s is the constructor parameter.
|