DCMTK Version 3.6.8
OFFIS DICOM Toolkit
|
provides an operating system independent abstraction for mutexes (mutual exclusion locks). More...
Public Member Functions | |
OFMutex () | |
default constructor | |
~OFMutex () | |
destructor | |
OFBool | initialized () const |
checks whether creation of the object was successful. More... | |
int | lock () |
locks the mutex object. More... | |
int | trylock () |
tries to lock the mutex object. More... | |
int | unlock () |
releases the lock on the mutex object. 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 trylock() method if the mutex is already locked. More... | |
Private Member Functions | |
OFMutex (const OFMutex &arg) | |
unimplemented private copy constructor | |
OFMutex & | operator= (const OFMutex &arg) |
unimplemented private assignment operator | |
Private Attributes | |
void * | theMutex |
mutex resource | |
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().
|
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 OFMutex::initialized | ( | ) | const |
checks whether creation of the object was successful.
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.
Referenced by OFshared_ptr< T >::Data::decrement_count(), OFGlobal< T >::get(), OFshared_ptr< T >::Data::increment_count(), OFGlobal< T >::set(), and OFGlobal< T >::xget().
int OFMutex::trylock | ( | ) |
tries to lock the mutex object.
If the mutex is already locked, returns OFMutex::busy.
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.
Referenced by OFshared_ptr< T >::Data::decrement_count(), OFGlobal< T >::get(), OFshared_ptr< T >::Data::increment_count(), OFGlobal< T >::set(), and OFGlobal< T >::xget().
|
static |