DCMTK  Version 3.6.1 20120515
OFFIS DICOM Toolkit
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
OFMutex Class Reference

provides an operating system independent abstraction for mutexes (mutual exclusion locks). More...

List of all members.

Public Member Functions

 OFMutex ()
 default constructor
 ~OFMutex ()
 destructor
OFBool initialized () const
 checks whether creation of the object was successful.
int lock ()
 locks the mutex object.
int trylock ()
 tries to lock the mutex object.
int unlock ()
 releases the lock on the mutex object.

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 trylock() method if the mutex is already locked.

Private Member Functions

 OFMutex (const OFMutex &arg)
 unimplemented private copy constructor
OFMutexoperator= (const OFMutex &arg)
 unimplemented private assignment operator

Private Attributes

void * theMutex
 mutex resource

Detailed Description

provides an operating system independent abstraction for mutexes (mutual exclusion locks).

Mutexes prevent multiple threads from simultaneously executing critical sections of code which access shared data. A successful call for a mutex lock by way of lock() will cause another thread that is also trying to lock the same mutex to block until the owner thread unlocks it by way of unlock().


Member Function Documentation

static void OFMutex::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
OFBool OFMutex::initialized ( ) const

checks whether creation of the object was successful.

Returns:
OFTrue if the object was successfully created, OFFalse otherwise.
int OFMutex::lock ( )

locks the mutex object.

If the mutex is already locked, the calling thread blocks until the mutex is freed; If the current owner of a mutex tries to relock the mutex, it may or may not result in deadlock.

Returns:
0 upon success, an error code otherwise.

tries to lock the mutex object.

If the mutex is already locked, returns OFMutex::busy.

Returns:
0 upon success, OFMutex::busy if the mutex is already locked, an error code otherwise.
int OFMutex::unlock ( )

releases the lock on the mutex object.

The mutex must be locked and the calling thread must be the owner of the lock, otherwise the behaviour is undefined. If there are threads blocked on the mutex when unlock() is called, one of them is unblocked and receives ownership of the mutex lock.

Returns:
0 upon success, an error code otherwise.

Member Data Documentation

const int OFMutex::busy [static]

this constant is returned by the trylock() method if the mutex is already locked.

Since this value is operating system dependent, comparisons should always compare the return value of trylock() with this constant.


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


Generated on Tue May 15 2012 for DCMTK Version 3.6.1 20120515 by Doxygen 1.7.5.1-20111027