// Name: thread.h
// Purpose: interface of all thread-related wxWidgets classes
// Author: wxWidgets team
-// RCS-ID: $Id$
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
*/
wxCondError Wait();
+ /**
+ Waits until the condition is signalled and the associated condition true.
+
+ This is a convenience overload that may be used to ignore spurious
+ awakenings while waiting for a specific condition to become true.
+
+ Equivalent to
+ @code
+ while ( !predicate() )
+ {
+ wxCondError e = Wait();
+ if ( e != wxCOND_NO_ERROR )
+ return e;
+ }
+ return wxCOND_NO_ERROR;
+ @endcode
+
+ The predicate would typically be a C++11 lambda:
+ @code
+ condvar.Wait([]{return value == 1;});
+ @endcode
+
+ @since 3.0
+ */
+ template<typename Functor>
+ wxCondError Wait(const Functor& predicate);
+
/**
Waits until the condition is signalled or the timeout has elapsed.
Example:
@code
- wxDECLARE_EVENT(wxEVT_COMMAND_MYTHREAD_UPDATE, wxThreadEvent);
+ wxDECLARE_EVENT(myEVT_THREAD_UPDATE, wxThreadEvent);
class MyFrame : public wxFrame, public wxThreadHelper
{
wxDECLARE_EVENT_TABLE();
};
- wxDEFINE_EVENT(wxEVT_COMMAND_MYTHREAD_UPDATE, wxThreadEvent)
+ wxDEFINE_EVENT(myEVT_THREAD_UPDATE, wxThreadEvent)
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
- EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_MYTHREAD_UPDATE, MyFrame::OnThreadUpdate)
+ EVT_THREAD(wxID_ANY, myEVT_THREAD_UPDATE, MyFrame::OnThreadUpdate)
EVT_CLOSE(MyFrame::OnClose)
wxEND_EVENT_TABLE()
The following symbolic constants can be used in addition to raw
values in 0..100 range:
- - ::wxPRIORITY_MIN: 0
- - ::wxPRIORITY_DEFAULT: 50
- - ::wxPRIORITY_MAX: 100
+ - @c wxPRIORITY_MIN: 0
+ - @c wxPRIORITY_DEFAULT: 50
+ - @c wxPRIORITY_MAX: 100
*/
void SetPriority(unsigned int priority);
This function can only be called from another thread context.
- @param waitMode
+ @param flags
As described in wxThreadWait documentation, wxTHREAD_WAIT_BLOCK
should be used as the wait mode even although currently
wxTHREAD_WAIT_YIELD is for compatibility reasons. This parameter is