#include <yateclass.h>
Public Member Functions | |
Lock2 (Mutex *mx1, Mutex *mx2, long maxwait=-1) | |
Lock2 (Mutex &mx1, Mutex &mx2, long maxwait=-1) | |
~Lock2 () | |
bool | locked () const |
bool | lock (Mutex *mx1, Mutex *mx2, long maxwait=-1) |
bool | lock (Mutex &mx1, Mutex &mx2, long maxwait=-1) |
void | drop () |
A dual lock is a stack allocated (automatic) object that locks a pair of mutexes on creation and unlocks them on destruction. The mutexes are always locked in the same order to prevent trivial deadlocks
Create the dual lock, try to lock each mutex
mx1 | Pointer to the first mutex to lock | |
mx2 | Pointer to the second mutex to lock | |
maxwait | Time in microseconds to wait for each mutex, -1 wait forever |
Create the dual lock, try to lock each mutex
mx1 | Reference to the first mutex to lock | |
mx2 | Reference to the second mutex to lock | |
maxwait | Time in microseconds to wait for each mutex, -1 wait forever |
~Lock2 | ( | ) | [inline] |
Destroy the lock, unlock the mutex if it was locked
void drop | ( | ) |
Unlock both mutexes if they were locked and drop the references
Lock in a new pair of mutexes
mx1 | Reference to the first mutex to lock | |
mx2 | Reference to the second mutex to lock | |
maxwait | Time in microseconds to wait for each mutex, -1 wait forever |
References Lock2::lock().
Referenced by Lock2::lock().
bool locked | ( | ) | const [inline] |
Check if the locking succeeded