#include <wefts_rmutex.h>
Inheritance diagram for Wefts::RMutex:
This mutex ensures that a calling thread can lock and unlock the mutex an equal amount of times without being blocked. This allows to wrap functions that are doing a lock on a mutex around outer functions that must extend the lock in a wider area, or use the mutex in a recursive function.
Public Member Functions | |
RMutex () | |
Initializes the internal data of the mutex. | |
virtual void | lock () |
Locks the mutex. | |
virtual bool | trylock () |
Tries to lock the mutex. | |
virtual void | unlock () |
Unlocks the mutex. | |
Private Attributes | |
OSThread | m_owner |
volatile int | m_lockCount |
|
Initializes the internal data of the mutex.
|
|
Locks the mutex. If the calling thread is already owning the lock, the function will return immediately. Anyhow, it is necessary to call the unlock() metod exactly the same amount of times that lock() has been called to ensure proper mutex releasing. Reimplemented from Wefts::Mutex. |
|
Tries to lock the mutex. Tries to lock the mutex, and immediately returns. If the mutex is free, the method locks it and returns true. If the mutex is locked by another thread, the method returns false. If the mutex is already held by the current thread, the mutex lock count is rise, and the method returns true.
Reimplemented from Wefts::Mutex. |
|
Unlocks the mutex. Releases the lock held by the calling thread. If the calling thread is not the rightful owner of the lock, the request is ignored and the call returns immediately. Reimplemented from Wefts::Mutex. |
|
|
|
|