#include <QThread.h>
This wait condition object functions very similarly to an event object in OS/2 or Win32. Essentially, this type of object acts like a soft drink dispenser - it holds the cans (threads) in a FIFO stack from which inseting a coin (wakeOne()) takes the bottom one out and dispenses it. You can also dispense all the cans at once (wakeAll()) which permits any new cans entered in the top to be dispensed straight away until reset() is called.
To use OS/2 speak, this object is signalled when it permits any thread trying to wait on to continue straight away. This continues until the object is reset to unsignalled, whereupon any waits will halt either indefinitely or the timeout period specified.
Unlike OS/2 or Win32, you are not guaranteed that the first thread to wait on the object will be the first thread released with wakeOne(). Due to POSIX limitations, the actual thread released will be random.
Public Member Functions | |
QWaitCondition (bool autoreset=false, bool initialstate=false) | |
bool | wait (FXuint time=FXINFINITE) |
void | wakeOne () |
void | wakeAll () |
void | reset () |
bool | signalled () const |
FX::QWaitCondition::QWaitCondition | ( | bool | autoreset = false , |
|
bool | initialstate = false | |||
) |
bool FX::QWaitCondition::wait | ( | FXuint | time = FXINFINITE |
) |
void FX::QWaitCondition::wakeOne | ( | ) |
Wakes a random thread waiting on this object. Never signals object.
void FX::QWaitCondition::wakeAll | ( | ) |
Signals object & wakes all threads waiting. If this is an autoreset object, object is reset after at least one thread is woken ie; if no threads are waiting when wakeAll() is called, object will remain signalled until one thread has tried to wait whereupon it will be permitted to continue - however subsequent waits will block.
void FX::QWaitCondition::reset | ( | ) |
Resets (unsignals) object. Any threads now trying to wait will be put to sleep.
bool FX::QWaitCondition::signalled | ( | ) | const [inline] |
Returns if the object is currently signalled or not.