ERC CISST - cisst software

osaMutex Class Reference
[OS Abstraction]

#include <osaMutex.h>

Collaboration diagram for osaMutex:

Collaboration graph
[legend]
List of all members.

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

Definition at line 47 of file osaMutex.h.

Public Types

Public Member Functions

Friends


Member Enumeration Documentation

enum osaMutex::TimeoutType

Definition at line 60 of file osaMutex.h.

enum osaMutex::ReturnType

Enum type for return values of a lock operation.

Definition at line 68 of file osaMutex.h.


Constructor & Destructor Documentation

osaMutex::osaMutex ( void   ) 

Default constructor. Initialize the underlying mutex.

osaMutex::~osaMutex ( void   ) 

Default destructor. Cleanup the underlying mutex.


Member Function Documentation

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.

Referenced by osaThreadedLogFileStreambuf< _element, _trait >::overflow(), osaThreadedLogFileStreambuf< _element, _trait >::sync(), and osaThreadedLogFileStreambuf< _element, _trait >::xsputn().

void osaMutex::Unlock ( void   ) 

Mutex unlock operation. Be careful, one should never unlock an already unlocked mutex, this would lead to undefined results.

Referenced by osaThreadedLogFileStreambuf< _element, _trait >::overflow(), osaThreadedLogFileStreambuf< _element, _trait >::sync(), and osaThreadedLogFileStreambuf< _element, _trait >::xsputn().

ReturnType osaMutex::TryLock ( int  timeout  ) 

Mutex lock operation with timeout

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


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu