X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fui_signaller.h;h=ee4d230d407e566114ae57b491700196c19d21c5;hb=09d7c1aeab76040e1dcbd829fbf734c4f4706180;hp=428ab698f1d3028f05c42705bb1ad76787120ba1;hpb=afc495f722f89fea0bcc579046d1a5d362e36f69;p=dcpomatic.git diff --git a/src/lib/ui_signaller.h b/src/lib/ui_signaller.h index 428ab698f..ee4d230d4 100644 --- a/src/lib/ui_signaller.h +++ b/src/lib/ui_signaller.h @@ -27,7 +27,7 @@ /** A class to allow signals to be emitted from non-UI threads and handled * by a UI thread. */ -class UISignaller +class UISignaller : public boost::noncopyable { public: /** Create a UISignaller. Must be called from the UI thread */ @@ -54,13 +54,23 @@ public: } } + /* Do something next time the UI is idle */ + template + void when_idle (T f) { + _service.post (f); + } + /** Call this in the UI when it is idle */ - void ui_idle () { - _service.poll (); + size_t ui_idle () { + /* This executes any functors that have been post()ed to _service */ + return _service.poll (); } /** This should wake the UI and make it call ui_idle() */ - virtual void wake_ui () = 0; + virtual void wake_ui () { + /* This is only a sensible implementation when there is no GUI... */ + ui_idle (); + } private: /** A io_service which is used as the conduit for messages */