A Read-Write lock object. More...
#include <sync.h>
Public Member Functions | |
void | rLock () |
void | rUnlock () |
void | wLock () |
void | wUnlock () |
A Read-Write lock object.
Simple implementation of the Readers-Writers problem, with priority to readers. A number of readers can obtain the rlock at the same time, while only one writer can obtain the wlock, and only if no writer has a wlock.
void RWLock::rLock | ( | ) |
Require the read-lock and stop the calling thread if another thread owns a write-lock.
void RWLock::rUnlock | ( | ) |
Release the read-lock and if the calling thread is the last reader unlock the writers (if any).
void RWLock::wLock | ( | ) |
Require the write-lock and stop the calling thread if another thread owns a read or a write lock.
void RWLock::wUnlock | ( | ) |
Release the write-lock and allow the access to other threads.