Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

phConditionCounter Class Reference
[Threading and SynchronizationThread Safe]

#include <phConditionCounter.h>

Inheritance diagram for phConditionCounter:

phCondition phMutex phObject List of all members.

Detailed Description

This is a Condition Counter class that allows for threads to block while waiting for a specific value setting. Threads will call phConditionCounter::waitForValue with a value parameter and a conditional operation choice to compare the passed value with the counter value. In order to provide the condition variable functionality, this class inherits from the phCondition class. The phConditionCounter::waitForValue method is a convenience because it simplifies the code at higher levels when a specific value is desired where hard looping or sleeping will impact performance. The waiting doesn't return until the condition is met whereas phConditon will return whenever the condition is signaled.

The phConditionCounter::waitForValue method that will not return until one of several conditions is met:

  1. Given a value and the condition operation (>, == , <=, etc.) the condition has become true. For example, the desired value is five and condition operation is equal-to/==; When the condition counter reaches the value of five, the method returns.
  2. The phConditionCounter::wakeup method was called
  3. An error occured while locking the object or receiving the signal.

Definition at line 99 of file phConditionCounter.h.

Public Member Functions

 phConditionCounter (intmax_t value=0)
 ~phConditionCounter ()
int increment (intmax_t inc_value=1)
int decrement (intmax_t dec_value=1)
int setValue (intmax_t value)
intmax_t getValue ()
int wakeup ()
int waitForValue (intmax_t value, int check_op, intmax_t *return_value=NULL)

Private Attributes

intmax_t m_value
int m_wake
intmax_t m_waiting

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

Copyright (C) 2002 - 2007 Philip D.S. Thoren ( )
University Of Massachusetts at Lowell
Robotics Lab Logo

Generated on Sat Jun 16 02:44:49 2007 for phission by  doxygen 1.4.4