|
|
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
inline Lock2 (Mutex* mx1, Mutex* mx2, long maxwait = -1)
| Lock2 |
Create the dual lock, try to lock each mutex
Parameters:
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 |
inline Lock2 (Mutex& mx1, Mutex& mx2, long maxwait = -1)
| Lock2 |
Create the dual lock, try to lock each mutex
Parameters:
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 |
inline ~Lock2 ()
| ~Lock2 |
Destroy the lock, unlock the mutex if it was locked
inline bool locked ()
| locked |
[const]
Check if the locking succeeded
Returns: True if all mutexes were locked
bool lock (Mutex* mx1, Mutex* mx2, long maxwait = -1)
| lock |
Lock in a new pair of mutexes. Any existing locks are dropped
Parameters:
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 |
Returns: True on success - non-NULL mutexes locked
inline bool lock (Mutex& mx1, Mutex& mx2, long maxwait = -1)
| lock |
Lock in a new pair of mutexes
Parameters:
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 |
Returns: True on success - both locked
void drop ()
| drop |
Unlock both mutexes if they were locked and drop the references
Generated by: paulc on bussard on Fri Dec 21 16:28:34 2012, using kdoc 2.0a54. |