BloombergLP::bslmt::Mutex

Portable wrapper of an OS-level mutex for intra-process synchronization.

Synopsis

Declared in <bslmt_mutex.h>

class Mutex;

Description

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.

Type Aliases

NameDescription
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

NameDescription
Mutex [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.
~Mutex [destructor]Destroy this mutex object. The behavior is undefined if the mutex is in a locked state.
lock Acquire a lock on this mutex, blocking if necessary.
nativeMutex Return a reference to the underlying OS-level mutex.
tryLock Attempt to acquire a lock on this mutex without blocking.
unlock Release a previously acquired lock on this mutex.