# class Mutex | Mutex support. More...
Full name | `TelEngine::Mutex`
Definition | `#include <yateclass.h>`
Inherits | TelEngine::Lockable [public ]
Inherited by | AnalogLine, AnalogLineGroup, ChanAssistList, ClientAccount, ClientAccountList, ClientDriver, DataSource, Driver, IAXEngine, IAXMetaTrunkFrame, IAXTransaction, ISDNIUAClient, ISDNQ931, ISDNQ931Call, ISDNQ931CallMonitor, ISDNQ931Monitor, JBClientEngine, JBClientStream, JBClusterStream, JBEngine, JBEntityCapsList, JBServerEngine, JBServerStream, JBStream, JBStreamSet, JBStreamSetList, JBStreamSetProcessor, JBStreamSetReceive, JGEngine, JGSession, JGSession0, JGSession1, MGCPEndpoint, MGCPEngine, MGCPTransaction, MessageDispatcher, MessageQueue, Module, MultiRouter, RTPGroup, RTPSession, SCCPManagement, SDPParser, SIGAdaptClient, SIGAdaptServer, SIGAdaptation, SIPEngine, SS7AnsiSccpManagement, SS7BICC, SS7ISUP, SS7ISUPCall, SS7ItuSccpManagement, SS7M2UAClient, SS7MTP2, SS7MTP3, SS7Management, SS7Route, SS7Router, SS7SCCP, SS7TCAPTransaction, SS7TCAPTransactionANSI, SS7TCAPTransactionITU, SS7TUP, SS7Testing, SccpLocalSubsystem, SccpRemote, ScriptRun, SharedVars, SignallingCall, SignallingCallControl, SignallingCircuitGroup, SignallingEngine, ThreadedSource, UDPTLSession
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- explicit Mutex (bool recursive = false, const char* name = 0)
- Mutex (const Mutex& original)
- ~Mutex ()
- Mutex& operator= (const Mutex& original)
- virtual bool lock (long maxwait = -1)
- virtual bool unlock ()
- virtual bool locked () const
- const char* owner () const
- bool recursive () const

#### Public Static Methods

- static int count ()
- static int locks ()
- static bool efficientTimedLock ()

## Detailed Description

A simple mutual exclusion for locking access between threads

explicit Mutex (bool recursive = false, const char* name = 0) | ### Mutex

Construct a new unlocked mutex

Parameters:

recursive | True if the mutex has to be recursive (reentrant), false for a normal fast mutex
name | Static name of the mutex (for debugging purpose only)

Mutex (const Mutex& original) | ### Mutex

Copy constructor, creates a shared mutex

Parameters:

original | Reference of the mutex to share

~Mutex () | ### ~Mutex

Destroy the mutex

Mutex& operator= (const Mutex& original) | ### operator=

Assignment operator makes the mutex shared with the original

Parameters:

original | Reference of the mutex to share

bool lock (long maxwait = -1) | ### lock

[virtual]

Attempt to lock the mutex and eventually wait for it

Parameters:

maxwait | Time in microseconds to wait for the mutex, -1 wait forever

Returns: True if successfully locked, false on failure

Reimplemented from Lockable.

bool unlock () | ### unlock

[virtual]

Unlock the mutex, does never wait

Returns: True if successfully unlocked the mutex

Reimplemented from Lockable.

bool locked () | ### locked

[const virtual]

Check if the mutex is currently locked - as it's asynchronous it guarantees nothing if other thread changes the mutex's status

Returns: True if the mutex was locked when the function was called

Reimplemented from Lockable.

const char* owner () | ### owner

[const]

Retrieve the name of the Thread (if any) holding the Mutex locked

Returns: Thread name() or NULL if thread not named

bool recursive () | ### recursive

[const]

Check if this mutex is recursive or not

Returns: True if this is a recursive mutex, false for a fast mutex

int count () | ### count

[static]

Get the number of mutexes counting the shared ones only once

Returns: Count of individual mutexes

int locks () | ### locks

[static]

Get the number of currently locked mutexes

Returns: Count of locked mutexes, -1 if unknown (not tracked)

bool efficientTimedLock () | ### efficientTimedLock

[static]

Check if a timed lock() is efficient on this platform

Returns: True if a lock with a maxwait parameter is efficiently implemented

Generated by: paulc on bussard on Mon Feb 10 13:15:47 2014, using kdoc 2.0a54.