cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
osaMutex Class Reference

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
 

Detailed Description

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).

Member Enumeration Documentation

Enum type for return values of a lock operation.

Enum type for current lock state

Enumerator
LOCKED 
UNLOCKED 
Enumerator
WAIT_FOREVER 
NO_WAIT 

The calling function will be blocked till the function returns

Constructor & Destructor Documentation

osaMutex::osaMutex ( void  )

Default constructor. Initialize the underlying mutex.

osaMutex::~osaMutex ( void  )

Default destructor. Cleanup the underlying mutex.

Member Function Documentation

LockStateType osaMutex::GetLockState ( void  ) const

Get current lock state

bool osaMutex::IsLocker ( void  ) const

Mutex lock operation with timeout

Parameters
timeoutIf 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.
Returns
An enumerated type representing if a lock was obtained, or operation timed out or lock failed

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.


The documentation for this class was generated from the following file: