From 0d436deb9ef8dc4af3b7e86fb72519e7ed8ed162 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 22 Dec 2016 04:04:41 +0100 Subject: [PATCH] clean-up and comments for the implementation finished thus far --- src/proc/control/looper.hpp | 34 +++++---- src/proc/control/proc-dispatcher.cpp | 10 ++- .../proc/control/dispatcher-looper-test.cpp | 10 ++- tests/gui/abstract-tangible-test.cpp | 3 +- wiki/thinkPad.ichthyo.mm | 72 ++++++++++++++----- 5 files changed, 92 insertions(+), 37 deletions(-) diff --git a/src/proc/control/looper.hpp b/src/proc/control/looper.hpp index a3e4bcbbb..804496c28 100644 --- a/src/proc/control/looper.hpp +++ b/src/proc/control/looper.hpp @@ -45,10 +45,7 @@ #include "lib/time/timevalue.hpp" #include "backend/real-clock.hpp" -//#include "common/subsys.hpp" -//#include "lib/depend.hpp" -//#include #include @@ -56,9 +53,6 @@ namespace proc { namespace control { -// using lib::Symbol; -// using std::bind; -// using std::function; using lib::time::Time; using lib::time::TimeVar; using lib::time::Offset; @@ -88,8 +82,21 @@ namespace control { } + /** - * @todo write Type-comment (WIP 12/2016) + * Encapsulated control logic for the session thread loop. + * This helper component was factored out from the loop body + * for sake of clarity and to allow unit testing of the logic + * in isolation. It is based on logical relations together + * with the following assumptions + * - Looper::shallLoop controls the loop's `while` condition + * - at the begin of the loop the thread possibly enters a blocking + * wait state; the wake-up condition is provided by Looper::requireAction. + * - then, in the actual loop body, depending on the predicates calculated here, + * either the builder run is triggered, or a single command is dispatched + * from the queue to work on the session. + * - after returning from these active operations, at the end of the loop, + * the state evaluation is updated by Looper::markStateProcessed * * @warning the Looper _is not threadsafe,_ * since it is intended to be run exclusively from @@ -144,6 +151,14 @@ namespace control { /** invoking this function signals * that all consequences of past state changes * have been processed and are duly resolved. + * @remark the implementation actually does not need to watch out + * for command processing state directly, only the managing + * of builder runs requires active state transitions here. + * When the conditions for triggering the Builder are met, + * control flow typically just has emptied the command queue. + * Thus we need to let one invocation pass by; the next loop iteration + * will begin after waking up from a short sleep and trigger the build, + * so the next (second) invocation can clear the builder dirty state. */ void markStateProcessed() @@ -191,10 +206,6 @@ namespace control { * (dirty_ and not isWorking()? 1 : slowdownFactor()); } - /* == diagnostics == */ - -// size_t size() const ; -// bool empty() const ; private: static uint wakeTimeout_ms(); @@ -203,7 +214,6 @@ namespace control { void startBuilderTimeout(); bool forceBuild() const; }; - ////////////////TODO 12/16 currently just fleshing out the API.... /** @internal establish the typical timeout for idle sleep. diff --git a/src/proc/control/proc-dispatcher.cpp b/src/proc/control/proc-dispatcher.cpp index 39dd4ae65..31e6a3a88 100644 --- a/src/proc/control/proc-dispatcher.cpp +++ b/src/proc/control/proc-dispatcher.cpp @@ -77,7 +77,7 @@ namespace control { public: DispatcherLoop (Subsys::SigTerm notification) : ThreadJoinable("Lumiera Session" - , bind (&DispatcherLoop::run, this, notification)) + , bind (&DispatcherLoop::runSessionThread, this, notification)) , commandService_(new SessionCommandService(*this)) , queue_() , looper_([&]() -> bool @@ -154,9 +154,13 @@ namespace control { } private: - /** the actual loop running in the Session thread */ + /** + * any operation running in the Session thread + * is started from here. When this loop terminates, + * the "Session subsystem" shuts down. + */ void - run (Subsys::SigTerm sigTerm) + runSessionThread (Subsys::SigTerm sigTerm) { string errorMsg; try diff --git a/tests/core/proc/control/dispatcher-looper-test.cpp b/tests/core/proc/control/dispatcher-looper-test.cpp index f39310045..a1d0e9eef 100644 --- a/tests/core/proc/control/dispatcher-looper-test.cpp +++ b/tests/core/proc/control/dispatcher-looper-test.cpp @@ -23,7 +23,6 @@ #include "lib/test/run.hpp" #include "proc/control/looper.hpp" -#include "lib/format-cout.hpp" #include #include @@ -303,6 +302,15 @@ namespace test { } + /** @test logic to trigger the builder over a complete simulated lifecycle. + * - when Looper::requireAction is true, the thread does not go into wait state + * - in the loop body + * * either when `runBuild()` is true, the builder run is triggered + * * or when `isWorking()` is true, the next command is processed + * - after that, Looper::markStateProcessed proceeds the state machine + * @note this test actually has to sleep in order to verify triggering a timeout + * + */ void verifyBuilderStart() { diff --git a/tests/gui/abstract-tangible-test.cpp b/tests/gui/abstract-tangible-test.cpp index 4c0eb4f6b..34d16d569 100644 --- a/tests/gui/abstract-tangible-test.cpp +++ b/tests/gui/abstract-tangible-test.cpp @@ -33,9 +33,8 @@ ** What is covered here is actually a **test mock**. Which in turn enables us ** to cover interface interactions and behaviour in a generic fashion, without ** actually having to operate the interface. But at the same time, this test - ** documents our generic UI element protocol and the corrsponding interactions. + ** documents our generic UI element protocol and the corresponding interactions. ** - ** @note as of 11/2015 this is a draft into the blue... ** @todo WIP ///////////////////////TICKET #959 : GUI Model / Bus ** @todo WIP ///////////////////////TICKET #956 : model diff representation ** @todo WIP ///////////////////////TICKET #961 : tests to pass... diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 8e6ea0e99..6437a5c76 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -11209,8 +11209,9 @@ - + + @@ -11286,9 +11287,9 @@ - + - + @@ -11298,18 +11299,24 @@ - - - - - + + + + + + + + + + + - - + + - - + + @@ -11335,7 +11342,8 @@ - + + @@ -11348,18 +11356,44 @@ - - + + + + + + + + + + - - + + + - - + + + + + + + + + +

+ Logik im Looper auf Basis +

+

+ generischer Überlegungen implementiert +

+ + +
+