|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |
#include "ot/base/RecursiveMutex.h"
Variety of mutex that can be locked multiple times by the same thread without blocking.
A mutex can be acquired (locked) by only one thread at a time. A RecursiveMutex can be locked multiple times by the same thread without blocking. It contains an internal usage count which is incremented by lock() and decremented by unlock(). When the internal usage count is decremented to zero the mutex is released and may be acquired by another thread.While a thread 'owns' the mutex (i.e. has it locked), it can safely use the protected resource, which may be a variable, a region of memory or anything else, in the knowledge that no other thread will be accessing it. However, this only holds true if all threads obey the rules and acquire the mutex before attempting to access the protected resource. This is where the 'mutual' part comes in - all programs that access the resource must acquire the mutex first.
Constructor/Destructor Summary | |
RecursiveMutex() Default constructor. |
Method Summary | |
bool |
isLocked() Tests if the mutex is currently owned by the current thread. |
void |
lock() Acquires the mutex. |
bool |
tryLock() Attempts to acquire the mutex without blocking. |
void |
unlock() Releases the mutex. |
Typedefs |
typedef AutoLock< RecursiveMutex > Lock
Constructor/Destructor Detail |
RecursiveMutex()
Method Detail |
bool isLocked()
void lock()
If the mutex is currently held by another thread this call blocks and waits until the mutex becomes available.
bool tryLock()
If the current thread already owns the mutex then the lock count is incremented. In this case unlock() must be called an equal number of times before the mutex will become released.
void unlock()
IllegalMonitorStateException
-
|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |