Hand-apply a2f81da6d9afc5d3b5e647e1e05ca5d4507af42c from master;
[dcpomatic.git] / src / lib / ui_signaller.h
index 73db8bff85d1b67b78c5e5c4704322ad1acc5528..ee4d230d407e566114ae57b491700196c19d21c5 100644 (file)
@@ -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,9 +54,16 @@ public:
                }
        }
 
+       /* Do something next time the UI is idle */
+       template <typename T>
+       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() */