core.sync.mutex

The mutex module provides a primitive for maintaining mutually exclusive access.

class Mutex

Types 1

classMutex : Object.Monitor

This class represents a general purpose, recursive mutex.

Implemented using pthread_mutex on Posix and CRITICAL_SECTION on Windows.

Fields
MonitorProxy m_proxy
Methods
void lock() @trustedIf this lock is not already held by the caller, the lock is acquired, then the internal counter is incremented by one.
void lock() @trusted sharedditto
void lock_nothrow(this Q)() if (is(Q == Mutex) || is(Q == shared Mutex)) nothrow @trusted @nogcditto
void unlock() @trustedDecrements the internal lock count by one. If this brings the count to zero, the lock is released.
void unlock() @trusted sharedditto
void unlock_nothrow(this Q)() if (is(Q == Mutex) || is(Q == shared Mutex)) nothrow @trusted @nogcditto
bool tryLock() @trustedIf the lock is held by another caller, the method returns. Otherwise, the lock is acquired if it is not already held, and then the internal counter is incremented by one.
bool tryLock() shared @trustedditto
bool tryLock_nothrow(this Q)() if (is(Q == Mutex) || is(Q == shared Mutex)) nothrow @trusted @nogcditto
Constructors
this()Initializes a mutex object.
this()ditto
this(bool _unused_)
this(Object obj)Initializes a mutex object and sets it as the monitor for `obj`.
this(Object obj)ditto
this(Object obj, bool _unused_)
Destructors
Nested Templates
MonitorProxy