Yate
|
Ephemeral mutex or semaphore locking object. More...
#include <yateclass.h>
Public Member Functions | |
Lock (Lockable &lck, long maxwait=-1) | |
Lock (Lockable *lck, long maxwait=-1) | |
~Lock () | |
Lockable * | locked () const |
void | drop () |
bool | acquire (Lockable *lck, long maxwait=-1) |
bool | acquire (Lockable &lck, long maxwait=-1) |
Ephemeral mutex or semaphore locking object.
A lock is a stack allocated (automatic) object that locks a lockable object on creation and unlocks it on destruction - typically when exiting a block
Create the lock, try to lock the object
lck | Reference to the object to lock |
maxwait | Time in microseconds to wait, -1 wait forever |
References Lockable::lock().
Create the lock, try to lock the object
lck | Pointer to the object to lock |
maxwait | Time in microseconds to wait, -1 wait forever |
References Lockable::lock().
|
inline |
Destroy the lock, unlock the mutex if it was locked
References Lockable::unlock().
|
inline |
Attempt to acquire a new lock on another object
lck | Pointer to the object to lock |
maxwait | Time in microseconds to wait, -1 wait forever |
References Lock::drop(), and Lockable::lock().
Referenced by Lock::acquire().
|
inline |
Attempt to acquire a new lock on another object
lck | Reference to the object to lock |
maxwait | Time in microseconds to wait, -1 wait forever |
References Lock::acquire().
|
inline |
Unlock the object if it was locked and drop the reference to it
References Lockable::unlock().
Referenced by Lock::acquire().
|
inline |
Return a pointer to the lockable object this lock holds