cisst-saw
|
Define a Mutex object. More...
#include <osaMutex.h>
Public Types | |
enum | TimeoutType { WAIT_FOREVER = -1, NO_WAIT = 0 } |
enum | LockStateType { LOCKED, UNLOCKED } |
Public Member Functions | |
osaMutex (void) | |
~osaMutex (void) | |
void | Lock (void) |
void | Unlock (void) |
bool | IsLocker (void) const |
LockStateType | GetLockState (void) const |
Define a Mutex object.
Mutex class provided to create mutual exclusion around critical sections. This class relies on Posix threads mutex when possible. On Windows, it uses an actual Mutex which provides a locking mechanism between threads as well as processes. It doesn't rely on the more specialized CriticalSection type (between threads only).
osaMutex::osaMutex | ( | void | ) |
Default constructor. Initialize the underlying mutex.
osaMutex::~osaMutex | ( | void | ) |
Default destructor. Cleanup the underlying mutex.
LockStateType osaMutex::GetLockState | ( | void | ) | const |
Get current lock state
bool osaMutex::IsLocker | ( | void | ) | const |
Mutex lock operation with timeout
timeout | If timeout == WAIT_FOREVER then the calling thread is blocked (this is same as calling Lock()). If timeout == NO_WAIT then the function returns after checking if the mutex can be locked or not. If timeout > 0 then the function waits for the specified amount of time (units to be specified later) before returning. |
Check if the current thread locked this mutex earlier
void osaMutex::Lock | ( | void | ) |
Mutex lock operation. This class doesn't use recursive mutexes therefore you must make sure the mutex is not already locked. Locking the same mutex twice from the same threads leads to undefined results.
void osaMutex::Unlock | ( | void | ) |
Mutex unlock operation. Be careful, one should never unlock an already unlocked mutex, this would lead to undefined results.