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

int phConditionCounter::waitForValue intmax_t  value,
int  check_op,
intmax_t return_value = NULL

This method waits for the condition counter variable to have a certain value as compared with a desired value using a check operation that compares them. This is a blocking method if the condition is not true at the time the calling thread enters the method. It use the phCondition::signalWait method to wait for signals and performs comparisons when those signals are received. Whenever one of the value adjusting methods of this class are called, a broadcast will be sent to wake up all the waiting threads. (These methods include phConditionCounter::setValue, phConditionCounter::decrement and phConditionCounter::increment.) When a thread is woken up it will perform the check_op comparison of choice between the passed value and the condition variable value phConditionCounter::m_value.

It may be the case that a thread was signaled because it is being woken up from a call to the phConditionCounter::wakeup method by another thread. If the thread is being woken up it will return whether or not the check_op comparison is true. The last thread to return from this method upon a wakeup signal will reset the phConditionCounter::m_wake value to it's normal 0. It is possible that a thread could come into the method during the wakeup procedure before phConditionCounter::m_wake value is reset and drop through.

[in] value The value to compare to the condition variable value using the check_op to compare the two.
[in] check_op This is the comparison operation to perform that determines when the method will return. Valid values include:
  • phCHECK_NE
  • phCHECK_E
  • phCHECK_GT
  • phCHECK_LT
[out] return_value The current counter variable is placed in this memory location so that the return code can be preserved for important return codes such as phConditionCounter_WAKEUP. The parameter is optional so the default pointer value is NULL. If phConditionCounter_WAKEUP was returned then this value was not set to the current counter value.
A value denoting the success of the waitForValue operation.
Return values:
phSUCCESS The wait operation was successful and the comparison check_op between value and the condition value is true.
phFAIL The method failed to execute properly.
phConditionCounter_WAKEUP The condition was signaled because the thread was woken up.

Definition at line 164 of file phConditionCounter.cpp.

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