move generic DispatchTimeout() implementation in the header as evtloopcmn.cpp is part of wxBase and so can't define a method of a wxCore class

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57575 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-27 00:04:57 +00:00
parent 6e7fd3ca03
commit 9c26672d4d
2 changed files with 15 additions and 22 deletions

View File

@@ -128,7 +128,7 @@ protected:
#include "wx/dfb/evtloop.h" #include "wx/dfb/evtloop.h"
#else // other platform #else // other platform
#define wxNEEDS_GENERIC_DISPATCH_TIMEOUT #include "wx/stopwatch.h" // for wxMilliClock_t
class WXDLLIMPEXP_FWD_CORE wxEventLoopImpl; class WXDLLIMPEXP_FWD_CORE wxEventLoopImpl;
@@ -142,7 +142,20 @@ public:
virtual void Exit(int rc = 0); virtual void Exit(int rc = 0);
virtual bool Pending() const; virtual bool Pending() const;
virtual bool Dispatch(); virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout); virtual int DispatchTimeout(unsigned long timeout)
{
// TODO: this is, of course, horribly inefficient and a proper wait with
// timeout should be implemented for all ports natively...
const wxMilliClock_t timeEnd = wxGetLocalTimeMillis() + timeout;
for ( ;; )
{
if ( Pending() )
return Dispatch();
if ( wxGetLocalTimeMillis() >= timeEnd )
return -1;
}
}
virtual void WakeUp() { } virtual void WakeUp() { }
protected: protected:

View File

@@ -28,7 +28,6 @@
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/app.h" #include "wx/app.h"
#include "wx/stopwatch.h" // for wxMilliClock_t
#endif //WX_PRECOMP #endif //WX_PRECOMP
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -155,22 +154,3 @@ void wxEventLoopManual::Exit(int rc)
#endif // __WXMSW__ || __WXMAC__ || __WXDFB__ #endif // __WXMSW__ || __WXMAC__ || __WXDFB__
#ifdef wxNEEDS_GENERIC_DISPATCH_TIMEOUT
int wxGUIEventLoop::DispatchTimeout(unsigned long timeout)
{
// TODO: this is, of course, horribly inefficient and a proper wait with
// timeout should be implemented for all ports natively...
const wxMilliClock_t timeEnd = wxGetLocalTimeMillis() + timeout;
for ( ;; )
{
if ( Pending() )
return Dispatch();
if ( wxGetLocalTimeMillis() >= timeEnd )
return -1;
}
}
#endif // wxNEEDS_GENERIC_DISPATCH_TIMEOUT