DCMTK  Version 3.6.3
OFFIS DICOM Toolkit
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
OFReadWriteLock Class Reference

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 unlock ()
 unlocks the read/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
 
OFReadWriteLockoperator= (const OFReadWriteLock &arg)
 unimplemented private assignment operator
 

Private Attributes

void * theLock
 read/write lock resource
 

Detailed Description

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.

Member Function Documentation

◆ errorstr()

static void OFReadWriteLock::errorstr ( OFString description,
int  code 
)
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.

Parameters
descriptionstring object into which the error description is written.
codeerror code

◆ initialized()

OFBool OFReadWriteLock::initialized ( ) const

checks whether creation of the object was successful.

Returns
OFTrue if the object was successfully created, OFFalse otherwise.

◆ rdlock()

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.

Returns
0 upon success, an error code otherwise.

◆ tryrdlock()

int OFReadWriteLock::tryrdlock ( )

trys to get a read lock.

If the read/write lock is locked for writing, returns OFReadWriteLock::busy.

Returns
0 upon success, OFReadWriteLock::busy if the read/write lock is already locked, an error code otherwise.

◆ trywrlock()

int OFReadWriteLock::trywrlock ( )

trys to get a write lock.

If the read/write lock is currently locked for reading or writing, returns OFReadWriteLock::busy.

Returns
0 upon success, OFReadWriteLock::busy if the read/write lock is already locked, an error code otherwise.

◆ unlock()

int OFReadWriteLock::unlock ( )

unlocks the read/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.

Returns
0 upon success, an error code otherwise.

◆ wrlock()

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.

Returns
0 upon success, an error code otherwise.

Member Data Documentation

◆ busy

const int OFReadWriteLock::busy
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.


The documentation for this class was generated from the following file:


Generated on Mon Feb 5 2018 for DCMTK Version 3.6.3 by Doxygen 1.8.14