Yate: WLock Class Reference

Yate

Public Member Functions | List of all members
WLock Class Reference

`#include <yateclass.h>`

## Public Member Functions
| WLock (RWLock &lck, long maxWait=-1)
| WLock (RWLock *lck, long maxWait=-1)
| ~WLock ()
RWLock * | locked () const
void | drop ()
bool | acquire (RWLock *lck, long maxWait=-1)
bool | acquire (RWLock &lck, long maxWait=-1)

## Detailed Description

Ephemeral read lock on a read-write lock (stack allocated lock that is locked on creation and unlocked in destructor

## Constructor & Destructor Documentation

## ◆ WLock() [1/2]

WLock | ( | RWLock & | lck,
|  | long | maxWait = -1 )
| inline

Create the lock, try to lock the object

Parameters

  lck | Reference to the object to lock
  maxWait | Time in microseconds to wait, -1 wait forever

References RWLock::writeLock().

## ◆ WLock() [2/2]

WLock | ( | RWLock * | lck,
|  | long | maxWait = -1 )
| inline

Create the lock, try to lock the object

Parameters

  lck | Pointer to the object to lock
  maxWait | Time in microseconds to wait, -1 wait forever

References RWLock::writeLock().

## ◆ ~WLock()

~WLock | ( |  | ) |
| inline

Destroy the lock, unlock the mutex if it was locked

## Member Function Documentation

## ◆ acquire() [1/2]

bool acquire | ( | RWLock & | lck,
|  | long | maxWait = -1 )
| inline

Attempt to acquire a new lock on another object

Parameters

  lck | Reference to the object to lock
  maxWait | Time in microseconds to wait, -1 wait forever

Returns
  True if locking succeeded or same object was locked

References acquire().

## ◆ acquire() [2/2]

bool acquire | ( | RWLock * | lck,
|  | long | maxWait = -1 )
| inline

Attempt to acquire a new lock on another object

Parameters

  lck | Pointer to the object to lock
  maxWait | Time in microseconds to wait, -1 wait forever

Returns
  True if locking succeeded or same object was locked

References drop(), and RWLock::writeLock().

Referenced by acquire().

## ◆ drop()

void drop | ( |  | ) |
| inline

Unlock the object if it was locked and drop the reference to it

Referenced by acquire().

## ◆ locked()

RWLock * locked | ( |  | ) | const
| inline

Return a pointer to the lockable object this lock holds

Returns
  A pointer to a Lockable or NULL if locking failed

The documentation for this class was generated from the following file:

- yateclass.h