Yate
RWLock Class Reference

Read/write lock support. More...

#include <yateclass.h>

Inheritance diagram for RWLock:
Lockable

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 RWLocklockableRWLock ()
 
- Public Member Functions inherited from Lockable
virtual ~Lockable ()
 
virtual bool check (long maxwait=-1)
 
virtual bool unlockAll ()
 
virtual MutexlockableMutex ()
 
virtual SemaphorelockableSemaphore ()
 

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
nameName of this lock

◆ RWLock() [2/2]

RWLock ( const RWLock & original)

Copy constructor, creates a RWLock semaphore

Parameters
originalReference 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
disableTrue to disable RW locks usage

◆ lock()

virtual bool lock ( long maxWait = -1)
inlinevirtual

Lock the write lock. This behaves like a mutex

Parameters
maxWaitTime 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
maxWaitTime 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
maxWaitTime 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: