[#BloombergLP-bslmt-ReaderWriterMutex]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::ReaderWriterMutex
:relfileprefix: ../../
:mrdocs:

This class provides a multi&hyphen;reader&sol;single&hyphen;writer lock mechanism&period;

== Synopsis

Declared in `&lt;bslmt&lowbar;readerwritermutex&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class ReaderWriterMutex;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslmt/ReaderWriterMutex/2constructor.adoc[`ReaderWriterMutex`]         [.small]#[constructor]#
| Construct a reader&sol;writer lock initialized to an unlocked state&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/isLocked.adoc[`isLocked`] 
| Return `true` if this reader&hyphen;write mutex is currently read locked or write locked, and `false` otherwise&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/isLockedRead.adoc[`isLockedRead`] 
| Return `true` if this reader&hyphen;write mutex is currently read locked, and `false` otherwise&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/isLockedWrite.adoc[`isLockedWrite`] 
| Return `true` if this reader&hyphen;write mutex is currently write locked, and `false` otherwise&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/lockRead.adoc[`lockRead`] 
| Lock this reader&hyphen;writer mutex for reading&period; If there are no active or pending write locks, lock this mutex for reading and return immediately&period; Otherwise, block until the read lock on this mutex is acquired&period; Use `unlockRead` or `unlock` to release the lock on this mutex&period; The behavior is undefined if this method is called from a thread that already has a lock on this mutex&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/lockWrite.adoc[`lockWrite`] 
| Lock this reader&hyphen;writer mutex for writing&period; If there are no active or pending locks on this mutex, lock this mutex for writing and return immediately&period; Otherwise, block until the write lock on this mutex is acquired&period; Use `unlockWrite` or `unlock` to release the lock on this mutex&period; The behavior is undefined if this method is called from a thread that already has a lock on this mutex&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/tryLockRead.adoc[`tryLockRead`] 
| Attempt to lock this reader&hyphen;writer mutex for reading&period; Immediately return 0 on success, and a non&hyphen;zero value if there are active or pending writers&period; If successful, `unlockRead` or `unlock` must be used to release the lock on this mutex&period; The behavior is undefined if this method is called from a thread that already has a lock on this mutex&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/tryLockWrite.adoc[`tryLockWrite`] 
| Attempt to lock this reader&hyphen;writer mutex for writing&period; Immediately return 0 on success, and a non&hyphen;zero value if there are active or pending locks on this mutex&period; If successful, `unlockWrite` or `unlock` must be used to release the lock on this mutex&period; The behavior is undefined if this method is called from a thread that already has a lock on this mutex&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/unlock.adoc[`unlock`] 
| Release the lock that the calling thread holds on this reader&hyphen;writer mutex&period; The behavior is undefined unless the calling thread currently has a lock on this mutex&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/unlockRead.adoc[`unlockRead`] 
| Release the read lock that the calling thread holds on this reader&hyphen;writer mutex&period; The behavior is undefined unless the calling thread currently has a read lock on this mutex&period;
| xref:BloombergLP/bslmt/ReaderWriterMutex/unlockWrite.adoc[`unlockWrite`] 
| Release the write lock that the calling thread holds on this reader&hyphen;writer mutex&period; The behavior is undefined unless the calling thread currently has a write lock on this mutex&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
