#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
|
|
Create the dual lock, try to lock each mutex
|
|
Destroy the lock, unlock the mutex if it was locked |
|
Unlock both mutexes if they were locked and drop the references |
|
Lock in a new pair of mutexes
|
|
Lock in a new pair of mutexes. Any existing locks are dropped
|
|
Check if the locking succeeded
|