nidas v1.2.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::util::Semaphore Class Reference

A POSIX semaphore. More...

#include <ThreadSupport.h>

Public Member Functions

 Semaphore ()
 Constructor.
 
 ~Semaphore ()
 Destructor.
 
void wait () throw ()
 Suspend calling thread until the semaphore has a non-zero count.
 
bool check () throw ()
 Do a non-blocking wait on the Semaphore.
 
void post () throw ()
 Atomically increment the Semaphore.
 
int getValue () throw ()
 Get the current value of the Semaphore.
 
sem_t * ptr ()
 Get the pointer to the semaphore (for legacy C code).
 

Private Member Functions

 Semaphore (const Semaphore &)
 No copying.
 
Semaphoreoperator= (const Semaphore &)
 No assignment allowed.
 

Private Attributes

sem_t _sem
 

Detailed Description

A POSIX semaphore.

Constructor & Destructor Documentation

◆ Semaphore() [1/2]

nidas::util::Semaphore::Semaphore ( )
inline

Constructor.

References _sem.

◆ ~Semaphore()

nidas::util::Semaphore::~Semaphore ( )
inline

Destructor.

References _sem.

◆ Semaphore() [2/2]

nidas::util::Semaphore::Semaphore ( const Semaphore & )
private

No copying.

Member Function Documentation

◆ check()

bool nidas::util::Semaphore::check ( )
throw ( )
inline

Do a non-blocking wait on the Semaphore.

Returns
true Semaphore had a non-zero count, which was decremented. false Semaphore was zero. Not changed.

References _sem.

◆ getValue()

int nidas::util::Semaphore::getValue ( )
throw ( )
inline

Get the current value of the Semaphore.

References _sem.

◆ operator=()

Semaphore & nidas::util::Semaphore::operator= ( const Semaphore & )
private

No assignment allowed.

◆ post()

void nidas::util::Semaphore::post ( )
throw ( )
inline

Atomically increment the Semaphore.

References _sem.

◆ ptr()

sem_t * nidas::util::Semaphore::ptr ( )
inline

Get the pointer to the semaphore (for legacy C code).

References _sem.

◆ wait()

void nidas::util::Semaphore::wait ( )
throw ( )
inline

Suspend calling thread until the semaphore has a non-zero count.

Then atomically decrement the semaphore count and return;

References _sem.

Member Data Documentation

◆ _sem

sem_t nidas::util::Semaphore::_sem
private

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