DCMTK Version 3.6.8
OFFIS DICOM Toolkit
|
provides an operating system independent abstraction for read/write locks. More...
Public Member Functions | |
OFReadWriteLock () | |
default constructor | |
~OFReadWriteLock () | |
destructor | |
OFBool | initialized () const |
checks whether creation of the object was successful. More... | |
int | rdlock () |
gets a read lock. More... | |
int | wrlock () |
gets a write lock. More... | |
int | tryrdlock () |
trys to get a read lock. More... | |
int | trywrlock () |
trys to get a write lock. More... | |
int | rdunlock () |
unlocks the read lock. More... | |
int | wrunlock () |
unlocks the write lock. More... | |
Static Public Member Functions | |
static void | errorstr (OFString &description, int code) |
converts any of the error codes returned by the methods of this class into a textual description, which is written into the string object. More... | |
Static Public Attributes | |
static const int | busy |
this constant is returned by the tryrdlock() and trywrlock() methods if the read/write lock is already locked. More... | |
Private Member Functions | |
OFReadWriteLock (const OFReadWriteLock &arg) | |
unimplemented private copy constructor | |
OFReadWriteLock & | operator= (const OFReadWriteLock &arg) |
unimplemented private assignment operator | |
Private Attributes | |
void * | theLock |
read/write lock resource | |
provides an operating system independent abstraction for read/write locks.
Many threads can have simultaneous read-only access to data, while only one thread can have write access at any given time. Multiple read access with single write access is controlled by read/write locks, which are generally used to protect data that is frequently searched.
|
static |
converts any of the error codes returned by the methods of this class into a textual description, which is written into the string object.
description | string object into which the error description is written. |
code | error code |
OFBool OFReadWriteLock::initialized | ( | ) | const |
checks whether creation of the object was successful.
int OFReadWriteLock::rdlock | ( | ) |
gets a read lock.
If the read/write lock is currently locked for writing, the calling thread blocks until the write lock is freed. Multiple threads may simultaneously hold a read lock on a read/write lock.
int OFReadWriteLock::rdunlock | ( | ) |
unlocks the read lock.
The read/write lock must be locked and the calling thread must be the owner of the lock, otherwise the behaviour is undefined. One of the other threads that is waiting for the read/write lock to be freed will be unblocked, provided there are other waiting threads.
int OFReadWriteLock::tryrdlock | ( | ) |
trys to get a read lock.
If the read/write lock is locked for writing, returns OFReadWriteLock::busy.
int OFReadWriteLock::trywrlock | ( | ) |
trys to get a write lock.
If the read/write lock is currently locked for reading or writing, returns OFReadWriteLock::busy.
int OFReadWriteLock::wrlock | ( | ) |
gets a write lock.
If the read/write lock is currently locked for reading or writing, the calling thread blocks until all the read and write locks are freed. At any given time, only one thread may have a write lock on a read/write lock.
int OFReadWriteLock::wrunlock | ( | ) |
unlocks the write lock.
The read/write lock must be locked and the calling thread must be the owner of the lock, otherwise the behaviour is undefined. One of the other threads that is waiting for the read/write lock to be freed will be unblocked, provided there are other waiting threads.
|
static |
this constant is returned by the tryrdlock() and trywrlock() methods if the read/write lock is already locked.
Since this value is operating system dependent, comparisons should always compare the return value of tryrdlock() and trywrlock() with this constant.