X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2e57ca641bf20456d33c9a885945230ecf17d261..92c0fc34c104c8d7c12d6a3b78ea232690fc23f4:/interface/wx/thread.h diff --git a/interface/wx/thread.h b/interface/wx/thread.h index 63eb7a1ef6..61becf5847 100644 --- a/interface/wx/thread.h +++ b/interface/wx/thread.h @@ -2,7 +2,6 @@ // Name: thread.h // Purpose: interface of all thread-related wxWidgets classes // Author: wxWidgets team -// RCS-ID: $Id$ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -170,6 +169,33 @@ public: */ 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 + wxCondError Wait(const Functor& predicate); + /** Waits until the condition is signalled or the timeout has elapsed. @@ -277,7 +303,7 @@ public: Example: @code - wxDECLARE_EVENT(wxEVT_COMMAND_MYTHREAD_UPDATE, wxThreadEvent); + wxDECLARE_EVENT(myEVT_THREAD_UPDATE, wxThreadEvent); class MyFrame : public wxFrame, public wxThreadHelper { @@ -310,9 +336,9 @@ public: 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() @@ -1218,9 +1244,9 @@ public: 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); @@ -1262,7 +1288,7 @@ public: 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