class Lock2

Ephemeral double mutex locking object. More...

Full nameTelEngine::Lock2
Definition#include <yateclass.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

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:
mx1Pointer to the first mutex to lock
mx2Pointer to the second mutex to lock
maxwaitTime 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:
mx1Reference to the first mutex to lock
mx2Reference to the second mutex to lock
maxwaitTime 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:
mx1Pointer to the first mutex to lock
mx2Pointer to the second mutex to lock
maxwaitTime 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:
mx1Reference to the first mutex to lock
mx2Reference to the second mutex to lock
maxwaitTime 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.