## wxCondition

wxCondition variables correspond to pthread conditions or to Win32 event objects. They may be used in a multithreaded application to wait until the given condition becomes true which happens when the condition becomes signaled.

For example, if a worker thread is doing some long task and another thread has to wait until it is finished, the latter thread will wait on the condition object and the worker thread will signal it on exit (this example is not perfect because in this particular case it would be much better to just Wait() for the worker thread, but if there are several worker threads it already makes much more sense).

Once the thread(s) are signaled, the condition then resets to the not signaled state, ready to fire again.

Derived from

None.

Include files

<wx/thread.h>

See also

wxThread, wxMutex

Members

wxCondition::wxCondition
wxCondition::~wxCondition
wxCondition::Broadcast
wxCondition::Signal
wxCondition::Wait

### wxCondition::wxCondition

wxCondition()

Default constructor.

### wxCondition::~wxCondition

~wxCondition()

Destroys the wxCondition object.

### wxCondition::Broadcast

void Broadcast()

Broadcasts to all waiting objects.

### wxCondition::Signal

void Signal()

Signals the object.

### wxCondition::Wait

void Wait()

Waits indefinitely.

bool Wait(unsigned long sec, unsigned long nsec)

Waits until a signal is raised or the timeout has elapsed.

Parameters

sec

Timeout in seconds

nsec

Timeout nanoseconds component (added to sec).

Return value

The second form returns if the signal was raised, or FALSE if there was a timeout.