The wakeup method allows waiting threads to be woken up if they are blocked on the condition variable. A specific return code will be returned from this method so that a thread can handle the wakeup procedure when it occurs.
The wakeup method works because only one thread is allowed access to the current instance of the object at any instance in time. This method sets the phConditionCounter::m_wake variable to 1 so that when any waiting thread recieves the broadcast, it will know that the broadcast was part of the wake up procedure. The last thread that exits the phConditionCounter::waitForValue() method will reset the phConditionCounter::m_wakeup variable to 0.
If any new thread goes into the waitForValue section while phConditionCounter::m_wake is set, they will drop through. If someone comes around after phConditionCounter::m_wake is reset by the last thread that was blocked in phConditionCounter::waitForValue(), those threads will likely block on the condition and not wakeup.
- Returns:
- The success value of the broadcast.
- Return values:
-
| phSUCCESS | The condition variable broadcast was successful and the phConditionCounter::m_wake variable was set to 1. |
| phFAIL | An error occured sending the broadcast signal to wakeup all the waiting threads. |
Definition at line 102 of file phConditionCounter.cpp. |