Yate
|
Ephemeral double mutex locking object. More...
#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 () |
Ephemeral double mutex locking object.
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 |
References Lock2::lock().
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 |
References Lock2::lock().
|
inline |
Destroy the lock, unlock the mutex if it was locked
References Lock2::drop().
void drop | ( | ) |
Unlock both mutexes if they were locked and drop the references
Referenced by Lock2::~Lock2().
Lock in a new pair of mutexes. Any existing locks are dropped
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 |
Referenced by Lock2::lock(), and Lock2::Lock2().
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().
|
inline |
Check if the locking succeeded