Refactor YieldFor() to avoid code duplication among the ports.

Don't repeat the same code in all the ports, move it to the common base class
and add a new virtual DoYieldFor() for the really port-specific code.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-03-02 18:58:00 +00:00
parent 632c106cd5
commit f740cc3881
19 changed files with 97 additions and 199 deletions

View File

@@ -153,7 +153,12 @@ public:
// may result in calling the same event handler again), use
// with _extreme_ care or, better, don't use at all!
bool Yield(bool onlyIfNeeded = false);
virtual bool YieldFor(long eventsToProcess) = 0;
// more selective version of Yield()
//
// notice that it is virtual for backwards-compatibility but new code
// should override DoYieldFor() and not YieldFor() itself
virtual bool YieldFor(long eventsToProcess);
// returns true if the main thread is inside a Yield() call
virtual bool IsYielding() const
@@ -182,6 +187,16 @@ protected:
// real implementation of Run()
virtual int DoRun() = 0;
// And the real, port-specific, implementation of YieldFor().
//
// The base class version is pure virtual to ensure that it is overridden
// in the derived classes but does have an implementation which processes
// pending events in wxApp if eventsToProcess allows it, and so should be
// called from the overridden version at an appropriate place (i.e. after
// processing the native events but before doing anything else that could
// be affected by pending events dispatching).
virtual void DoYieldFor(long eventsToProcess) = 0;
// this function should be called before the event loop terminates, whether
// this happens normally (because of Exit() call) or abnormally (because of
// an exception thrown from inside the loop)
@@ -313,10 +328,10 @@ public:
}
}
virtual void WakeUp() { }
virtual bool YieldFor(long eventsToProcess);
protected:
virtual int DoRun();
virtual void DoYieldFor(long eventsToProcess);
// the pointer to the port specific implementation class
wxEventLoopImpl *m_impl;