API FOR ADVANCED USERS – A readers/writer lock is used to allow concurrent access to readers and unique access to writers. More...
#include <ilserver/ilthread.h>
Public Member Functions | |
IlsRWLock (IlsUnsafeMutex *=0) | |
Constructor. More... | |
IlsBoolean | rdlock () |
This member function blocks until the thread acquires a read lock. More... | |
IlsBoolean | unlock () |
This member function unlocks the lock that was previously taken by the thread. More... | |
IlsBoolean | wrlock () |
This member function blocks until the thread acquires a write lock. More... | |
Public Member Functions inherited from IlsMTBase | |
virtual | ~IlsMTBase () |
This is the public virtual destructor for this class. | |
virtual IlsThreadObjectName | getName () const |
This member function returns the name of an object. More... | |
Friends | |
ostream & | operator<< (ostream &, const IlsRWLock &) |
This operator prints the name of the object to the output stream. More... | |
API FOR ADVANCED USERS – A readers/writer lock is used to allow concurrent access to readers and unique access to writers.
Library: server
and mvcomp
Certain error conditions are detected and flagged, such as an attempt to take a read lock when the thread already has a write lock, and vice versa. In these cases, the lock()
member functions return IlsFalse
. The scheduling is done so that writers have priority. Hence, if a reader is running, new readers will be allowed just until a writer is blocked.
Once a writer is waiting, all new readers will block until there are no more waiting writers. It is possible to provide the pointer to the mutex to use to protect the readers/writer lock. For details, see IlsCond
.
IlsCond
, IlsRWLocker
, IlsThread
, IlsUnsafeMutex
. IlsRWLock::IlsRWLock | ( | IlsUnsafeMutex * | = 0 | ) |
Constructor.
If a mutex is passed to the constructor, then it is the responsibility of the application to lock the mutex before accessing member functions.
IlsBoolean IlsRWLock::rdlock | ( | ) |
This member function blocks until the thread acquires a read lock.
It returns IlsFalse
if an error occurs or if the thread already has a write lock.
IlsBoolean IlsRWLock::unlock | ( | ) |
IlsBoolean IlsRWLock::wrlock | ( | ) |
This member function blocks until the thread acquires a write lock.
It returns IlsFalse
if an error occurs or if the thread already has a read lock.