From d8c19c7a321d6955c0233bfac4e0664140a4a48f Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 10 Aug 2017 18:05:05 +0200 Subject: [PATCH] UI-Dispatch: complete implementation of the hand-over (closes #1098) ...by integrating and wiring a Glib::Dispatcher --- src/gui/ctrl/ui-dispatcher.hpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gui/ctrl/ui-dispatcher.hpp b/src/gui/ctrl/ui-dispatcher.hpp index 4b3c197bf..e022cba2b 100644 --- a/src/gui/ctrl/ui-dispatcher.hpp +++ b/src/gui/ctrl/ui-dispatcher.hpp @@ -69,23 +69,34 @@ namespace ctrl { : boost::noncopyable { lib::CallQueue queue_; + Glib::Dispatcher dispatcher_; using Operation = lib::CallQueue::Operation; public: UiDispatcher() : queue_{} - { } - + , dispatcher_{} + { + dispatcher_.connect( + [this]() { + queue_.invoke(); + }); + } + /** + * move the given operation into our private dispatcher queue and + * then schedule dequeuing and invocation into the UI event thread. + * @param op a completely closed lambda or functor + * @warning closure need to be by value or equivalent, since + * the operation will be executed in another call stack + */ void event (Operation&& op) { queue_.feed (move(op)); - //////////////////////////TODO trigger Glib::Dispatcher!!!!! + dispatcher_.emit(); } - - private: };