Public Member Functions | Private Member Functions | Private Attributes
USemaphore Class Reference

#include <USemaphore.h>

List of all members.

Public Member Functions

bool acquire (int n=1, int ms=0)
int acquireTry (int n)
void release (int n=1)
 USemaphore (int initValue=0)
int value ()
virtual ~USemaphore ()

Private Member Functions

void operator= (const USemaphore &S)
 USemaphore (const USemaphore &S)

Private Attributes

int _available
pthread_cond_t _cond
pthread_mutex_t _waitMutex

Detailed Description

A semaphore class.

On an acquire() call, the calling thread is blocked if the USemaphore's value is <= 0. It is unblocked when release() is called. The function acquire() decreases by 1 (default) the semaphore's value and release() increases it by 1 (default).

Example:

 USemaphore s;
 s.acquire(); // Will wait until s.release() is called by another thread.
See also:
UMutex

Definition at line 54 of file USemaphore.h.


Constructor & Destructor Documentation

USemaphore::USemaphore ( int  initValue = 0) [inline]

The constructor. The semaphore waits on acquire() when its value is <= 0.

Parameters:
nnumber to initialize

Definition at line 61 of file USemaphore.h.

virtual USemaphore::~USemaphore ( ) [inline, virtual]

Definition at line 72 of file USemaphore.h.

USemaphore::USemaphore ( const USemaphore S) [inline, private]

Definition at line 216 of file USemaphore.h.


Member Function Documentation

bool USemaphore::acquire ( int  n = 1,
int  ms = 0 
) [inline]

Acquire the semaphore. If semaphore's value is <=0, the calling thread will wait until the count acquired is released.

See also:
release()
Parameters:
nnumber to acquire
ttime to wait (ms), a value <=0 means infinite
Returns:
true on success, false on error/timeout

Definition at line 101 of file USemaphore.h.

int USemaphore::acquireTry ( int  n) [inline]

Definition at line 144 of file USemaphore.h.

void USemaphore::operator= ( const USemaphore S) [inline, private]

Definition at line 211 of file USemaphore.h.

void USemaphore::release ( int  n = 1) [inline]

Release the semaphore, increasing its value by 1 and signaling waiting threads (which called acquire()).

Definition at line 168 of file USemaphore.h.

int USemaphore::value ( ) [inline]

Get the USempahore's value.

Returns:
the semaphore's value

Definition at line 187 of file USemaphore.h.


Member Data Documentation

int USemaphore::_available [private]

Definition at line 219 of file USemaphore.h.

pthread_cond_t USemaphore::_cond [private]

Definition at line 218 of file USemaphore.h.

pthread_mutex_t USemaphore::_waitMutex [private]

Definition at line 217 of file USemaphore.h.


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


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:31