YANE-Framework 1.1.0
Public Member Functions

yane::Utils::Mutex Class Reference

Mutex class. More...

List of all members.

Public Member Functions

virtual bool isLocked ()
 Return wether the mutex is locked or unlocked.
virtual void lock ()
 Lock the mutex.
 Mutex ()
 Constructor.
virtual bool trylock ()
 Try to lock the mutex.
virtual void unlock ()
 Unlock the mutex.
 ~Mutex ()
 Destructor.

Detailed Description

Class to use and create mutex objects. A mutex is needed if two or more threads read or write a shared object. Usually this class is used as following:


Constructor & Destructor Documentation

LIB_EXPORT yane::Utils::Mutex::Mutex ( )

Create new mutex object.

Exceptions:
threadExceptionThrown if mutex creation failed
LIB_EXPORT yane::Utils::Mutex::~Mutex ( )

Destroys the object.


Member Function Documentation

LIB_EXPORT bool yane::Utils::Mutex::isLocked ( ) [virtual]

Return wether the mutex is locked or unlocked.

Returns:
True if locked, false if unlocked.
LIB_EXPORT void yane::Utils::Mutex::lock ( ) [virtual]

Try to lock the mutex. If mutex is already locked, the function is waiting until the mutex is unlocked.

Exceptions:
threadExceptionThrown if lock failed because of technical reasons
LIB_EXPORT bool yane::Utils::Mutex::trylock ( ) [virtual]

Try to lock the mutex. If mutex is already locked, the function returns.

Returns:
True if successful, false if an error occurred.
LIB_EXPORT void yane::Utils::Mutex::unlock ( ) [virtual]

Unlock the mutex.

Exceptions:
threadExceptionThrown if unlock failed because of technical reasons