FX::QWaitCondition Class Reference

#include <QThread.h>

List of all members.


Detailed Description

An OS/2 style event object (Qt compatible).

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.

Note:
On all platforms QWaitCondition will cancel the thread during a wait if a cancellation has been requested. Please consult the documentation for QThread.
Warning:
POSIX does not guarantee that POSIX wait conditions can be used from cleanup/signal handlers (most annoyingly). Indeed FreeBSD aborts the process if you try which is even more serious, so QWaitCondition::wait() issues a warning on all platforms in debug mode.

Public Member Functions

 QWaitCondition (bool autoreset=false, bool initialstate=false)
bool wait (FXuint time=FXINFINITE)
void wakeOne ()
void wakeAll ()
void reset ()
bool signalled () const

Constructor & Destructor Documentation

FX::QWaitCondition::QWaitCondition ( bool  autoreset = false,
bool  initialstate = false 
)

Parameters:
autoreset When true, object automatically reset()'s itself after releasing all threads with a wakeAll()
initialstate When true, object starts life signalled


Member Function Documentation

bool FX::QWaitCondition::wait ( FXuint  time = FXINFINITE  ) 

Returns:
True if wait succeeded, false if it timed out Waits time milliseconds for the object to become signalled. FXINFINITE specifies wait forever.

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.


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

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 22:28:54 2008 for TnFOX by doxygen v1.5.6