#include <yateclass.h>
Inheritance diagram for Mutex:
Public Member Functions | |
Mutex () | |
Mutex (bool recursive) | |
Mutex (const Mutex &original) | |
~Mutex () | |
Mutex & | operator= (const Mutex &original) |
bool | lock (long maxwait=-1) |
void | unlock () |
bool | locked () const |
bool | check (long maxwait=-1) |
bool | recursive () const |
Static Public Member Functions | |
static int | count () |
static int | locks () |
static void | wait (unsigned long maxwait) |
Friends | |
class | MutexPrivate |
A simple mutual exclusion for locking access between threads
Mutex | ( | ) |
Construct a new unlocked fast mutex
Mutex | ( | bool | recursive | ) |
Construct a new unlocked mutex
recursive | True if the mutex has to be recursive (reentrant), false for a normal fast mutex |
Copy constructor creates a shared mutex
original | Reference of the mutex to share |
~Mutex | ( | ) |
Destroy the mutex
Assignment operator makes the mutex shared with the original
original | Reference of the mutex to share |
bool lock | ( | long | maxwait = -1 |
) |
Attempt to lock the mutex and eventually wait for it
maxwait | Time in microseconds to wait for the mutex, -1 wait forever |
void unlock | ( | ) |
Unlock the mutex, does never wait
bool locked | ( | ) | const |
Check if the mutex is currently locked - as it's asynchronous it guarantees nothing if other thread changes the mutex's status
bool check | ( | long | maxwait = -1 |
) |
Check if the mutex is unlocked (try to lock and unlock the mutex)
maxwait | Time in microseconds to wait for the mutex, -1 wait forever |
bool recursive | ( | ) | const |
Check if this mutex is recursive or not
static int count | ( | ) | [static] |
Get the number of mutexes counting the shared ones only once
static int locks | ( | ) | [static] |
Get the number of currently locked mutexes
static void wait | ( | unsigned long | maxwait | ) | [static] |
Set a maximum mutex wait time for debugging purposes
maxwait | Maximum time in microseconds to wait for any mutex when no time limit was requested, zero to disable limit |