My Project
Public Member Functions | Protected Attributes | List of all members
ParaEngine::Semaphore Class Reference

cross platform condition variable. More...

#include <Semaphore.hpp>

Public Member Functions

 Semaphore (int in_init=0)
 Constructor. More...
 
 Semaphore (const Semaphore &in_sem)
 Copy constructor. More...
 
void operator= (const Semaphore &in_sem)
 Copy method. More...
 
virtual ~Semaphore ()
 destroy semaphore
 
bool wait () const
 Wait until the semaphore is called by another thread. More...
 
bool post ()
 post a token More...
 
int value () const
 get current value More...
 
void reset (int in_init=0)
 release current semaphore and create a new one More...
 

Protected Attributes

sem_t _sem
 Posix semaphore.
 

Detailed Description

cross platform condition variable.

This class represent a simple way to use semaphore

Constructor & Destructor Documentation

§ Semaphore() [1/2]

ParaEngine::Semaphore::Semaphore ( int  in_init = 0)
inline

Constructor.

Parameters
in_initoriginal value

§ Semaphore() [2/2]

ParaEngine::Semaphore::Semaphore ( const Semaphore in_sem)
inline

Copy constructor.

Parameters
in_semoriginal semaphore

Member Function Documentation

§ operator=()

void ParaEngine::Semaphore::operator= ( const Semaphore in_sem)
inline

Copy method.

Parameters
in_semoriginal semaphore

§ post()

bool ParaEngine::Semaphore::post ( )
inline

post a token

Returns
true if success or false if error

§ reset()

void ParaEngine::Semaphore::reset ( int  in_init = 0)
inline

release current semaphore and create a new one

Parameters
initthe value after reset

§ value()

int ParaEngine::Semaphore::value ( ) const
inline

get current value

Returns
value

§ wait()

bool ParaEngine::Semaphore::wait ( ) const
inline

Wait until the semaphore is called by another thread.

Returns
true if success or false if timeout or error

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