diff --git a/src/proc/control/looper.hpp b/src/proc/control/looper.hpp index 6edd3fb7b..ad6866770 100644 --- a/src/proc/control/looper.hpp +++ b/src/proc/control/looper.hpp @@ -58,10 +58,22 @@ namespace control { // using lib::Symbol; // using std::bind; + namespace { + /** + * @todo this value should be retrieved from configuration ////////////////////////////////TICKET #1052 : access application configuration + * @see Looper::establishWakeTimeout() + */ + const uint PROC_DISPATCHER_BUILDER_DELAY_ms = 50; + } /** - * @todo Type-comment + * @todo write Type-comment (WIP 12/2016) + * + * @warning the Looper _is not threadsafe,_ + * since it is intended to be run exclusively from + * the Session working thread. + * @see DispatcherLoop::run() */ class Looper { @@ -70,6 +82,37 @@ namespace control { Looper() { } + /* == working state == */ + + bool isWorking() const { return false; } + bool isIdle() const { return false; } + bool needBuild() const { return false; } + bool isDisabled() const { return false; } + bool isDying() const { return false; } + + + /** state fusion to control (timed) wait */ + bool + requireAction() + { + return isWorking() + or needBuild() + or isDying(); + } + + /** state fusion to control looping */ + bool + shallLoop() const + { + return not isDying(); + } + + ulong + getTimeout() const + { + static uint wakeTimeout_ms = establishWakeTimeout(); + return wakeTimeout_ms; + } /* == diagnostics == */ @@ -77,10 +120,28 @@ namespace control { // size_t size() const ; // bool empty() const ; + private: + static uint establishWakeTimeout(); }; ////////////////TODO 12/16 currently just fleshing out the API.... + /** @internal establish the typical timeout for idle sleep. + * When the ProcDispatcher has no work to do, it needs to wake up regularly + * for a checkpoint, to determine if the Builder needs to be triggered or + * the shutdown-flag be checked. So the period established here defines + * some kind of minimal reaction especially for the builder, so to ensure + * that further commands trickling in get a chance to be enqueued before + * the builder run effectively blocks command processing. Add to this + * the typical average running time of the builder, to get the reaction + * period visible to the user as update response delay within the UI. + * @todo find a way how to retrieve this value from application config! ////////////////////TICKET #1052 : access application configuration + */ + uint + Looper::establishWakeTimeout() + { + return PROC_DISPATCHER_BUILDER_DELAY_ms; + } }} // namespace proc::control diff --git a/src/proc/control/proc-dispatcher.cpp b/src/proc/control/proc-dispatcher.cpp index 090518334..f5ff88161 100644 --- a/src/proc/control/proc-dispatcher.cpp +++ b/src/proc/control/proc-dispatcher.cpp @@ -53,7 +53,7 @@ namespace control { { bool canDispatch_{false}; bool blocked_ {false}; - bool mustHalt_ {false}; + bool mustHalt_ {false}; /////////////////TODO this flag shall be relocated into the Looper! unique_ptr commandService_; @@ -134,8 +134,16 @@ namespace control { string errorMsg; try { - TODO ("actually do something in the loop"); /////////////////////////////////////////TODO *** THIS NEXT TO IMPLEMENT !!!! *** - sleep(2); + while (looper_.shallLoop()) + { + awaitAction(); + if (looper_.isDying()) break; + if (looper_.needBuild()) + startBuilder(); + else + if (looper_.isWorking()) + processCommands(); + } } catch (lumiera::Error& problem) { @@ -146,20 +154,42 @@ namespace control { { errorMsg = string{lumiera_error()}; } + // now leave the Session thread... + // send notification of subsystem shutdown sigTerm (&errorMsg); } + void + awaitAction() + { + Lock(this).wait(looper_, + &Looper::requireAction, + looper_.getTimeout()); + } + + void + processCommands() + { + UNIMPLEMENTED ("pull commands from the queue and dispatch them"); + } + + void + startBuilder() + { + UNIMPLEMENTED ("start the Proc-Builder to recalculate render nodes network"); + } }; + + /** storage for Singleton access */ lib::Depend ProcDispatcher::instance; - /** */ bool ProcDispatcher::start (Subsys::SigTerm termNotification) diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index cacab2536..9e14607d8 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -11048,13 +11048,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + +

+ ...und dann nur noch +

+
    +
  • + auf Shutdown reagieren +
  • +
  • + mitbekommen wenn die Sperre aufgehoben wird +
  • +
+ + +
+
+
- + +