Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Wefts::Cond Class Reference

Class implementing a condition variable. More...

#include <wefts_cond.h>

Inheritance diagram for Wefts::Cond:

Inheritance graph
[legend]
List of all members.

Public Methods

virtual int wait ()
 Waits for the condition to be active.

virtual int wait (long seconds, long nanoseconds)
 Waits for the condition to be active up to a certain time.

int wait (double seconds)
 Waits for the condition to be active for a certain time.

virtual void signal ()
 Signals the condition.


Protected Methods

 Cond ()
 Initializes the internal data of the condition.

 ~Cond ()

Protected Attributes

pthread_cond_t m_cond
 Internal condition variable.

pthread_mutex_t * m_my_mutex
 Internal mutex.


Detailed Description

Class implementing a condition variable.

This condition class is meant to be overloaded by classes using specific mutex types. To use it, you have to create your own class using a combination of this class plus a fast or a reentrant mutex. This is implemented in the wtFastCondition and wtRCondition classes.

Subclassess must set my_my_mutex to a valid pthread mutex pointer

All condition classes are implemented via inline calls to maximize execution speed; also, their metods are extremely small.


Constructor & Destructor Documentation

Wefts::Cond::Cond   [inline, protected]
 

Initializes the internal data of the condition.

Initialization of m_my_mutex member is left to subclasses.

Wefts::Cond::~Cond   [inline, protected]
 


Member Function Documentation

virtual void Wefts::Cond::signal   [inline, virtual]
 

Signals the condition.

When a condition is signaled all the waiting threads are given a chance to go.

int Wefts::Cond::wait double    seconds [inline]
 

Waits for the condition to be active for a certain time.

Works as wait( long seconds, long nanoseconds), but the wait time can be expressed as a real number, 1.0 meaning a second.

ams seconds time to wait for (seconds and fraction of seconds expressed as decimal part)
Returns:
0 if condition is signaled, non zero (posix pthread error) otherwise.

virtual int Wefts::Cond::wait long    seconds,
long    nanoseconds
[inline, virtual]
 

Waits for the condition to be active up to a certain time.

This method works as wait() but returns (with nonzero value) if a certain time has elapsed. If you call this function, you have to specify the amount of seconds and second fractions (expressed in nanoseconds) you want to wait for a single event to be risen. Granularity of the system greatly depends on underlying OS and process priviledges.

Parameters:
seconds  integer count of seconds to wait for.
nanoseconds  integer count of nanoseconds to wait for (maximum is 999,999,999).
Returns:
0 if condition is signaled, non zero (posix pthread error) otherwise.

virtual int Wefts::Cond::wait   [inline, virtual]
 

Waits for the condition to be active.

This method waits forever or until stopped by an external event (signal).

Returns:
0 if condition is signaled, non zero (posix pthread error) otherwise.


Member Data Documentation

pthread_cond_t Wefts::Cond::m_cond [protected]
 

Internal condition variable.

pthread_mutex_t* Wefts::Cond::m_my_mutex [protected]
 

Internal mutex.

Subclasses are invited to set this mutex to an initialized specific kind of mutex at creation.

Todo:
use Mutex class instead of pthread mutex


The documentation for this class was generated from the following file:
Generated on Tue Aug 5 18:09:03 2003 for Wefts by doxygen1.2.18