RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
USemaphore Class Reference

#include <USemaphore.h>

Public Member Functions

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

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:

s.acquire(); // Will wait until s.release() is called by another thread.
bool acquire(int n=1, int ms=0)
Definition USemaphore.h:108
See also
UMutex

Definition at line 55 of file USemaphore.h.

Constructor & Destructor Documentation

◆ USemaphore()

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 62 of file USemaphore.h.

◆ ~USemaphore()

virtual USemaphore::~USemaphore ( )
inlinevirtual

Definition at line 76 of file USemaphore.h.

Member Function Documentation

◆ acquire()

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 108 of file USemaphore.h.

◆ acquireTry()

int USemaphore::acquireTry ( int  n)
inline
Parameters
nthe number to acquire.

Definition at line 164 of file USemaphore.h.

◆ release()

int USemaphore::release ( int  n = 1)
inline

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

Parameters
nthe number to release.
Returns
0 on success, ERANGE if the release would push the semaphore over SEM_VALUE_MAX (the count is then left unchanged). The Unix implementation cannot fail and always returns 0.

Definition at line 197 of file USemaphore.h.

◆ value()

int USemaphore::value ( )
inline

Get the USempahore's value.

Returns
the semaphore's value

Definition at line 221 of file USemaphore.h.


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