BloombergLP::bslmt::RWMutex

Platform-independent interface to a reader-writer mutex.

Synopsis

Declared in <bslmt_rwmutex.h>

class RWMutex;

Description

This class is a platform-independent interface to a reader-writer lock ("RW mutex"). Multiple readers can safely hold the lock simultaneously, whereas only one writer is allowed to hold the lock at a time. This class uses the most efficient RW mutex implementation available for the current platform. Note that the implementation may allow readers to starve writers.

Member Functions

NameDescription
RWMutex [constructor]Create an RW mutex initialized to an unlocked state.
~RWMutex [destructor]Destroy this RW mutex. The behavior is undefined if the mutex is in a locked state.
lockRead Lock this reader-writer mutex for reading.
lockWrite Lock this reader-writer mutex for writing.
tryLockRead Attempt to lock this reader-writer mutex for reading.
tryLockWrite Attempt to lock this reader-writer mutex for writing.
unlock Release the lock held by the calling thread on this mutex.