RTT::os::Semaphore Class Reference

#include <Semaphore.hpp>

List of all members.

Public Member Functions

 Semaphore (int count)
 Semaphore (int count)
void signal ()
void signal ()
bool trywait ()
bool trywait ()
int value ()
int value ()
void wait ()
void wait ()
bool waitUntil (nsecs abs_time)
bool waitUntil (Seconds abs_time)
bool waitUntil (nsecs abs_time)
bool waitUntil (Seconds abs_time)
 ~Semaphore ()
 ~Semaphore ()

Private Attributes

rt_sem_t sem

Detailed Description

An object oriented wrapper around a counting semaphore. It works like a traffic light on which a thread can wait() until the sempahore's value becomes positive, otherwise it blocks. Another thread then needs to signal() the semaphore. One thread which is waiting will then be awakened, if none is waiting, the first thread calling wait() will continue directly (and decrease the value by 1).

Warning:
Semaphore instances should only be created in soft realtime, since the initialisation of a semaphore can not be done in hard realtime.

Definition at line 61 of file install/include/rtt/os/Semaphore.hpp.


Constructor & Destructor Documentation

RTT::os::Semaphore::Semaphore ( int  count  )  [inline]

Initialize a Semaphore with an initial count.

See also:
value() to retrieve the current count.

Definition at line 70 of file install/include/rtt/os/Semaphore.hpp.

RTT::os::Semaphore::~Semaphore (  )  [inline]

Destroy a Semaphore.

Definition at line 78 of file install/include/rtt/os/Semaphore.hpp.

RTT::os::Semaphore::Semaphore ( int  count  )  [inline]

Initialize a Semaphore with an initial count.

See also:
value() to retrieve the current count.

Definition at line 70 of file rtt/os/Semaphore.hpp.

RTT::os::Semaphore::~Semaphore (  )  [inline]

Destroy a Semaphore.

Definition at line 78 of file rtt/os/Semaphore.hpp.


Member Function Documentation

void RTT::os::Semaphore::signal (  )  [inline]

Raise this semaphore and signal one thread waiting on this semaphore.

Definition at line 96 of file rtt/os/Semaphore.hpp.

void RTT::os::Semaphore::signal (  )  [inline]

Raise this semaphore and signal one thread waiting on this semaphore.

Definition at line 96 of file install/include/rtt/os/Semaphore.hpp.

bool RTT::os::Semaphore::trywait (  )  [inline]

Try to wait on this semaphore

Returns:
true when the locking succeeded ( this->value() was > 0), false otherwise ( this->value() was = 0 )

Definition at line 106 of file rtt/os/Semaphore.hpp.

bool RTT::os::Semaphore::trywait (  )  [inline]

Try to wait on this semaphore

Returns:
true when the locking succeeded ( this->value() was > 0), false otherwise ( this->value() was = 0 )

Definition at line 106 of file install/include/rtt/os/Semaphore.hpp.

int RTT::os::Semaphore::value (  )  [inline]

Return the current count of this semaphore.

Definition at line 145 of file rtt/os/Semaphore.hpp.

int RTT::os::Semaphore::value (  )  [inline]

Return the current count of this semaphore.

Definition at line 145 of file install/include/rtt/os/Semaphore.hpp.

void RTT::os::Semaphore::wait (  )  [inline]

Lower this semaphore and return if value() is non zero. Or wait if value() is zero until a signal occurs.

Definition at line 87 of file rtt/os/Semaphore.hpp.

void RTT::os::Semaphore::wait (  )  [inline]

Lower this semaphore and return if value() is non zero. Or wait if value() is zero until a signal occurs.

Definition at line 87 of file install/include/rtt/os/Semaphore.hpp.

bool RTT::os::Semaphore::waitUntil ( nsecs  abs_time  )  [inline]

Wait on this semaphore until a maximum absolute time.

Parameters:
abs_time Absolute time in nano seconds until which to wait on this semaphore.
Return values:
true if the semaphore was signaled before abs_time expired.
false if the semaphore was not signaled.
See also:
rtos_get_time_ns() to get the current time in nano seconds.

Definition at line 134 of file rtt/os/Semaphore.hpp.

bool RTT::os::Semaphore::waitUntil ( Seconds  abs_time  )  [inline]

Wait on this semaphore until a maximum absolute time.

Parameters:
abs_time Absolute time in seconds until which to wait on this semaphore.
Return values:
true if the semaphore was signaled before abs_time expired.
false if the semaphore was not signaled.
See also:
rtos_get_time_ns() to get the current time in nano seconds.

Definition at line 120 of file rtt/os/Semaphore.hpp.

bool RTT::os::Semaphore::waitUntil ( nsecs  abs_time  )  [inline]

Wait on this semaphore until a maximum absolute time.

Parameters:
abs_time Absolute time in nano seconds until which to wait on this semaphore.
Return values:
true if the semaphore was signaled before abs_time expired.
false if the semaphore was not signaled.
See also:
rtos_get_time_ns() to get the current time in nano seconds.

Definition at line 134 of file install/include/rtt/os/Semaphore.hpp.

bool RTT::os::Semaphore::waitUntil ( Seconds  abs_time  )  [inline]

Wait on this semaphore until a maximum absolute time.

Parameters:
abs_time Absolute time in seconds until which to wait on this semaphore.
Return values:
true if the semaphore was signaled before abs_time expired.
false if the semaphore was not signaled.
See also:
rtos_get_time_ns() to get the current time in nano seconds.

Definition at line 120 of file install/include/rtt/os/Semaphore.hpp.


Member Data Documentation

Definition at line 64 of file install/include/rtt/os/Semaphore.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


rtt
Author(s): RTT Developers
autogenerated on Fri Jan 11 09:50:10 2013