X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e48a3055145e5d3f77b17383ed7521585ea7391d..2887cb4e38d0cd2064105ca7e363d8641d364871:/src/dfb/evtloop.cpp?ds=sidebyside diff --git a/src/dfb/evtloop.cpp b/src/dfb/evtloop.cpp index 52b940c9f4..3cc18ac290 100644 --- a/src/dfb/evtloop.cpp +++ b/src/dfb/evtloop.cpp @@ -25,7 +25,9 @@ #include "wx/app.h" #endif +#include "wx/thread.h" #include "wx/timer.h" +#include "wx/private/socketevtdispatch.h" #include "wx/dfb/private.h" #define TRACE_EVENTS _T("events") @@ -85,11 +87,18 @@ bool wxEventLoop::Dispatch() // NB: we don't block indefinitely waiting for an event, but instead // time out after a brief period in order to make sure that // OnNextIteration() will be called frequently enough - // - // FIXME: call NotifyTimers() from here (and loop) instead? const int TIMEOUT = 100; - if ( ms_buffer->WaitForEventWithTimeout(0, TIMEOUT) ) + // release the GUI mutex so that other threads have a chance to post + // events: + wxMutexGuiLeave(); + + bool rv = ms_buffer->WaitForEventWithTimeout(0, TIMEOUT); + + // and acquire it back before calling any event handlers: + wxMutexGuiEnter(); + + if ( rv ) { switch ( ms_buffer->GetLastResult() ) { @@ -126,9 +135,23 @@ void wxEventLoop::WakeUp() void wxEventLoop::OnNextIteration() { #if wxUSE_TIMER - // see the comment in Dispatch wxTimer::NotifyTimers(); #endif + +#if wxUSE_SOCKETS + // handle any pending socket events: + wxSocketEventDispatcher::Get().RunLoop(); +#endif +} + +void wxEventLoop::Yield() +{ + // process all pending events: + while ( Pending() ) + Dispatch(); + + // handle timers, sockets etc. + OnNextIteration(); }