Base Framework
|
Read-write synchronization object. More...
#include <base/concurrency/ReadWriteLock.h>
Public Types | |
typedef ExclusiveSynchronize< ReadWriteLock > | Sync |
![]() | |
typedef ExclusiveSynchronize< Lock > | Sync |
Public Member Functions | |
ReadWriteLock () | |
void | exclusiveLock () const |
bool | tryExclusiveLock () const |
void | sharedLock () const |
bool | trySharedLock () const |
void | releaseLock () const |
~ReadWriteLock () | |
![]() | |
String | getDescription () const |
void | setDescription (const String &description) |
unsigned int | getResourceId () const |
unsigned int | getCreatedById () const |
AnyReference | getHandle () const noexcept |
template<class TYPE > | |
TYPE & | getInternalHandle () const |
operator bool () const noexcept | |
![]() | |
Lock () noexcept | |
virtual | ~Lock () |
Additional Inherited Members | |
![]() | |
AnyReference | handle |
Read-write synchronization object.
The ReadWriteLock class implements a read-write lock for optimal reader performance on systems which have rwlock support and reverts to a simple mutex for those that do not. Please note that the lock/unlock mechanism is considered a non-modifying property of a class.
ReadWriteLock::ReadWriteLock | ( | ) |
Initializes a read-write lock in the unlocked state. Raises ResourceException if unable to initialize the object.
ReadWriteLock::~ReadWriteLock | ( | ) |
Destroys the read-write lock object. The lock must be in the unlocked state prior to destruction. Raises ReadWriteLockException on failure.
|
virtual |
Acquires an exclusive lock (write-lock) on the read-write lock. The calling thread acquires the lock if no other thread (reader or writer) currently holds the lock. Otherwise, the thread blocks until the lock can be acquired. Results are undefined if the calling thread holds the read-write lock. Raises ReadWriteLockException on failure.
Implements Lock.
|
virtual |
This method unlocks the read-write lock. Results are undefines if the calling thread does not hold the lock. Raises the exception ReadWriteLockException on failure.
Implements Lock.
|
virtual |
Acquires a shared lock (read-lock) on the read-write lock. The calling thread blocks until the lock can be acquired. Results are undefined if the calling thread already holds a lock. Raises the exception ReadWriteLockException on failure.
Implements Lock.
|
virtual |
Attempts to acquire an exclusive lock on the read-write lock. Raises the exception ReadWriteLockException on failure.
Implements Lock.
|
virtual |
Attempts to acquire a shared lock on the read-write lock. Raises the exception ReadWriteLockException on failure.
Implements Lock.