Loading...
Searching...
No Matches
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.
int | rdlock ()
| gets a read lock.
int | wrlock ()
| gets a write lock.
int | tryrdlock ()
| trys to get a read lock.
int | trywrlock ()
| trys to get a write lock.
int | rdunlock ()
| unlocks the read lock.
int | wrunlock ()
| unlocks the write lock.

## 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.

## 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.

## Private Member Functions

| OFReadWriteLock (const OFReadWriteLock &arg)
| unimplemented private copy constructor
OFReadWriteLock & | operator= (const OFReadWriteLock &arg)
| unimplemented private assignment operator

## Private Attributes

volatile 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()

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

  description | string object into which the error description is written.
  code | error 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.

## rdunlock()

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.

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.

## 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.

## wrunlock()

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.

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:

- ofstd/include/dcmtk/ofstd/ofthread.h

Generated on for DCMTK Version 3.7.0 by Doxygen 1.15.0