[#BloombergLP-bslmt-Mutex] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::Mutex :relfileprefix: ../../ :mrdocs: This `class` implements a lightweight, portable wrapper of an OS‐level mutex lock to support intra‐process synchronization. The behavior is undefined if the `lock` method of this class is invoked more than once on the same mutex object in the same thread without an intervening call to `unLock`. == Synopsis Declared in `<bslmt_mutex.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class Mutex; ---- == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/Mutex/NativeType.adoc[`NativeType`] | `NativeType` is an alias for the underlying OS‐level mutex type. It is exposed so that other `bslmt` components can operate directly on this mutex. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/Mutex/2constructor.adoc[`Mutex`] [.small]#[constructor]# | Create a mutex object in the unlocked state. This method does not return normally unless there are sufficient system resources to construct the object. | xref:BloombergLP/bslmt/Mutex/2destructor.adoc[`~Mutex`] [.small]#[destructor]# | Destroy this mutex object. The behavior is undefined if the mutex is in a locked state. | xref:BloombergLP/bslmt/Mutex/lock.adoc[`lock`] | Acquire a lock on this mutex object. If this object is currently locked by a different thread, then suspend execution of the current thread until a lock can be acquired. The behavior is undefined if the calling thread already owns the lock on this mutex, and may result in deadlock. | xref:BloombergLP/bslmt/Mutex/nativeMutex.adoc[`nativeMutex`] | Return a reference to the modifiable OS‐level mutex underlying this object. This method is intended only to support other `bslmt` components that must operate directly on this mutex. | xref:BloombergLP/bslmt/Mutex/tryLock.adoc[`tryLock`] | Attempt to acquire a lock on this mutex object. Return 0 on success, and a non‐zero value if this object is already locked by a different thread. The behavior is undefined if the calling thread already owns the lock on this mutex, and may result in deadlock. | xref:BloombergLP/bslmt/Mutex/unlock.adoc[`unlock`] | Release a lock on this mutex that was previously acquired through a call to `lock`, or a successful call to `tryLock`, enabling another thread to acquire a lock on this mutex. The behavior is undefined unless the calling thread currently owns the lock on this mutex. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#