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

This `class` implements a recursive mutex (i&period;e&period;, a mutex that can be locked any number of times by a thread, and then released by unlocking the mutex the same number of times)&period; If there is an efficient native recursive mutex, this class wraps it&period; Otherwise, a reasonably efficient proprietary implementation is used&period; Note that `Mutex` should be preferred if at all possible&period;

== Synopsis

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

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

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslmt/RecursiveMutex/2constructor.adoc[`RecursiveMutex`]         [.small]#[constructor]#
| Create a recursive mutex object in the unlocked state&period; This method does not return normally unless there are sufficient system resources to construct the object&period;
| xref:BloombergLP/bslmt/RecursiveMutex/2destructor.adoc[`&#126;RecursiveMutex`] [.small]#[destructor]#
| Destroy this recursive mutex object&period;
| xref:BloombergLP/bslmt/RecursiveMutex/lock.adoc[`lock`] 
| Acquire a lock on this object&period; If this object is currently locked, then suspend execution of the current thread until a lock can be acquired&period; Succeed immediately if this thread already holds the lock&period;
| xref:BloombergLP/bslmt/RecursiveMutex/tryLock.adoc[`tryLock`] 
| Attempt to acquire a lock on this object&period; Return 0 on success, and a non&hyphen;zero value if this object is already locked by another thread, or if an error occurs&period; Succeed immediately if this thread already holds the lock&period;
| xref:BloombergLP/bslmt/RecursiveMutex/unlock.adoc[`unlock`] 
| Release a lock on this object that was previously acquired through a call to `lock`, or a successful call to `tryLock`&period; To fully release the lock, a thread must invoke `unlock` the same number of times it invoked `lock` and `tryLock`&period; The behavior is undefined unless the calling thread currently owns the lock on this recursive mutex&period;
|===



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