Yate: RWLock Class Reference

Yate

Public Member Functions | Static Public Member Functions | Friends | List of all members
RWLock Class Reference

Read/write lock support. More...

`#include <yateclass.h>`

Inheritance diagram for RWLock:

## Public Member Functions
| RWLock (const char *name=0)
| RWLock (const RWLock &original)
| ~RWLock ()
virtual bool | unlock ()
bool | readLock (long maxWait=-1)
bool | writeLock (long maxWait=-1)
virtual bool | lock (long maxWait=-1)
virtual bool | locked () const
virtual RWLock * | lockableRWLock ()
Public Member Functions inherited from Lockable
virtual | ~Lockable ()
virtual bool | check (long maxwait=-1)
virtual bool | unlockAll ()
virtual Mutex * | lockableMutex ()
virtual Semaphore * | lockableSemaphore ()

## Static Public Member Functions
static void | disableRWLock (bool disable)
Static Public Member Functions inherited from Lockable
static void | wait (unsigned long maxwait)
static unsigned long | wait ()
static void | startUsingNow ()
static void | enableSafety (bool safe=true)
static bool | safety ()

## Friends
class | RWLockPrivate

## Detailed Description

Read/write lock support.

A read/write lock

## Constructor & Destructor Documentation

## ◆ RWLock() [1/2]

RWLock | ( | const char * | name = 0 | ) |

Build a read/write lock

Parameters

  name | Name of this lock

## ◆ RWLock() [2/2]

RWLock | ( | const RWLock & | original | ) |

Copy constructor, creates a RWLock semaphore

Parameters

  original | Reference of the semaphore to share

## ◆ ~RWLock()

~RWLock | ( |  | ) |

Destructor

## Member Function Documentation

## ◆ disableRWLock()

static void disableRWLock | ( | bool | disable | ) |
| static

Debugging method for disabling RW locks usage and replacing it with a non-recursive mutex

Parameters

  disable | True to disable RW locks usage

## ◆ lock()

virtual bool lock | ( | long | maxWait = -1 | ) |
| inlinevirtual

Lock the write lock. This behaves like a mutex

Parameters

  maxWait | Time to wait for locking to succeed, -1 to wait forever, 0 return immediately

Returns
  True if locking succeed

Implements Lockable.

## ◆ lockableRWLock()

virtual RWLock * lockableRWLock | ( |  | ) |
| inlinevirtual

Retrieve a RWLock from this object

Returns
  RWLock pointer

Reimplemented from Lockable.

## ◆ locked()

virtual bool locked | ( |  | ) | const
| virtual

Check if the object is currently locked - as it's asynchronous it guarantees nothing if other thread changes the status

Returns
  True if the object was locked when the function was called

Implements Lockable.

## ◆ readLock()

bool readLock | ( | long | maxWait = -1 | ) |

Lock the read lock.

Parameters

  maxWait | Time to wait for locking to succeed, -1 to wait forever, 0 return immediately

Returns
  True if locking succeed

Referenced by Lock::acquire(), RLock::acquire(), RLock::RLock(), and RLock::RLock().

## ◆ unlock()

virtual bool unlock | ( |  | ) |
| virtual

Unlock either the read or write lock held by the calling thread

Returns
  True if anything was unlocked

Implements Lockable.

## ◆ writeLock()

bool writeLock | ( | long | maxWait = -1 | ) |

Lock the write lock.

Parameters

  maxWait | Time to wait for locking to succeed, -1 to wait forever, 0 return immediately

Returns
  True if locking succeed

Referenced by WLock::acquire(), WLock::WLock(), and WLock::WLock().

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

- yateclass.h