%% options copyright owner = Dirk Krause copyright year = 2013-xxxx license = bsd %% header #include /** Protect idle event handler from concurrent execution. In contrast to a critical section which delays execution of code this class skips the code execution. */ class DkWxProcessingIdleController : public DkWxProcessingController { protected: /** Avoid concurrent access to bWantMore. */ wxMutex mxProtectWantMore; /** Flag: More idle events wanted. */ bool bWantMore; public: /** Constructor. */ DkWxProcessingIdleController(); /** Indicate interest in more idle events (thread-safe). @param value New flag value. */ void setWantMore(bool value = true); /** Indicate no more interest in further idle events (thread-safe). */ void resetWantMore(void); /** Check for interest in further idle events (thread-safe). @return true to ask for further events, false otherwise. */ bool wantMore(void); }; %% module #include "DkWxProcessingIdleController.h" $!trace-include DkWxProcessingIdleController::DkWxProcessingIdleController() : DkWxProcessingController() { bWantMore = false; } void DkWxProcessingIdleController::setWantMore(bool value) { wxMutexLocker lock(mxProtectWantMore); bWantMore = value; } void DkWxProcessingIdleController::resetWantMore(void) { wxMutexLocker lock(mxProtectWantMore); bWantMore = false; } bool DkWxProcessingIdleController::wantMore(void) { bool back = false; { wxMutexLocker lock(mxProtectWantMore); back = bWantMore; } return back; }