Mutex Class Reference

Mutex support. More...

#include <yateclass.h>

Inheritance diagram for Mutex:
Lockable AnalogLine ClientAccount ClientAccountList DataSource IAXEngine IAXMetaTrunkFrame IAXTransaction JBEngine JBService JGSession JIDResourceList MessageDispatcher MGCPEndpoint MGCPEngine MGCPTransaction Module MultiRouter RTPGroup SDPParser SignallingCall SignallingCallControl SignallingCircuitGroup SignallingEngine SIPEngine SS7MTP2 SS7MTP3 SS7Route SS7Router XMLParser XMPPUser XMPPUserRoster

List of all members.

Public Member Functions

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

Static Public Member Functions

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

Friends

class MutexPrivate

Detailed Description

Mutex support.

A simple mutual exclusion for locking access between threads


Constructor & Destructor Documentation

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

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  ) 

Copy constructor, creates a shared mutex

Parameters:
original Reference of the mutex to share
~Mutex (  ) 

Destroy the mutex


Member Function Documentation

static int count (  )  [static]

Get the number of mutexes counting the shared ones only once

Returns:
Count of individual mutexes
static bool efficientTimedLock (  )  [static]

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

Returns:
True if a lock with a maxwait parameter is efficiently implemented
virtual bool lock ( long  maxwait = -1  )  [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

Implements Lockable.

virtual bool 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

Implements Lockable.

static int locks (  )  [static]

Get the number of currently locked mutexes

Returns:
Count of locked mutexes, should be zero at program exit
Mutex& operator= ( const Mutex original  ) 

Assignment operator makes the mutex shared with the original

Parameters:
original Reference of the mutex to share
const char* 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 (  )  const

Check if this mutex is recursive or not

Returns:
True if this is a recursive mutex, false for a fast mutex
virtual bool unlock (  )  [virtual]

Unlock the mutex, does never wait

Returns:
True if successfully unlocked the mutex

Implements Lockable.


The documentation for this class was generated from the following file:
Generated on Thu Apr 8 18:19:41 2010 for Yate by  doxygen 1.6.3