Yate
Mutex Class Reference

Mutex support. More...

#include <yateclass.h>

Inheritance diagram for Mutex:
Lockable AnalogLine IAXEngine IAXMetaTrunkFrame IAXTransaction MGCPEndpoint MGCPEngine MGCPTransaction MultiRouter RTPGroup RTPSession SCCPManagement SDPParser SIGAdaptation SIPEngine SIPSequence SS7MTP2 SS7MTP3 SS7Management SS7Route SS7Router SS7SCCP SS7TCAPTransaction SS7Testing SccpLocalSubsystem SccpRemote ScriptMutex SignallingCall SignallingCallControl SignallingCircuitGroup SignallingEngine ClientAccount ClientAccountList DataSource JBEngine JBEntityCapsList JBStream JBStreamSet JBStreamSetList JGEngine JGSession MessageDispatcher MessageQueue Module SharedVars UDPTLSession

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
 
- Public Member Functions inherited from Lockable
virtual ~Lockable ()
 
virtual bool check (long maxwait=-1)
 
virtual bool unlockAll ()
 

Static Public Member Functions

static int count ()
 
static int locks ()
 
static bool efficientTimedLock ()
 
- Static Public Member Functions inherited from Lockable
static void wait (unsigned long maxwait)
 
static unsigned long wait ()
 
static void startUsingNow ()
 
static void enableSafety (bool safe=true)
 
static bool safety ()
 

Friends

class MutexPrivate
 

Detailed Description

Mutex support.

A simple mutual exclusion for locking access between threads

Constructor & Destructor Documentation

◆ Mutex() [1/2]

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

Construct a new unlocked mutex

Parameters
recursiveTrue if the mutex has to be recursive (reentrant), false for a normal fast mutex
nameStatic name of the mutex (for debugging purpose only)

References recursive().

Referenced by IAXEngine::bind(), ClientAccountList::ClientAccountList(), DataSource::DataSource(), JBEntityCapsList::JBEntityCapsList(), Mutex(), operator=(), ScriptMutex::ScriptMutex(), SDPParser::SDPParser(), SharedVars::SharedVars(), SIPSequence::SIPSequence(), SS7Route::SS7Route(), SS7Route::SS7Route(), and SS7Testing::SS7Testing().

◆ Mutex() [2/2]

Mutex ( const Mutex & original)

Copy constructor, creates a shared mutex

Parameters
originalReference of the mutex to share

References Mutex().

◆ ~Mutex()

~Mutex ( )

Destroy the mutex

Member Function Documentation

◆ count()

static int count ( )
static

Get the number of mutexes counting the shared ones only once

Returns
Count of individual mutexes

◆ efficientTimedLock()

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

◆ lock()

◆ locked()

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.

◆ locks()

static int locks ( )
static

Get the number of currently locked mutexes

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

◆ operator=()

Mutex & operator= ( const Mutex & original)

Assignment operator makes the mutex shared with the original

Parameters
originalReference of the mutex to share

References Mutex().

◆ owner()

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

Referenced by JBStreamSet::JBStreamSet(), JBStreamSetProcessor::JBStreamSetProcessor(), and JBStreamSetReceive::JBStreamSetReceive().

◆ recursive()

bool recursive ( ) const

Check if this mutex is recursive or not

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

Referenced by Mutex(), and ScriptMutex::ScriptMutex().

◆ unlock()

virtual bool unlock ( )
virtual

Unlock the mutex, does never wait

Returns
True if successfully unlocked the mutex

Implements Lockable.

Referenced by SIPEngine::append(), MGCPEndpoint::clear(), SIPEngine::insert(), and SIPEngine::remove().


The documentation for this class was generated from the following file: