clean-up and comments for the implementation finished thus far
This commit is contained in:
parent
99b9af0a74
commit
0d436deb9e
5 changed files with 92 additions and 37 deletions
|
|
@ -45,10 +45,7 @@
|
|||
|
||||
#include "lib/time/timevalue.hpp"
|
||||
#include "backend/real-clock.hpp"
|
||||
//#include "common/subsys.hpp"
|
||||
//#include "lib/depend.hpp"
|
||||
|
||||
//#include <memory>
|
||||
#include <functional>
|
||||
|
||||
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "lib/test/run.hpp"
|
||||
#include "proc/control/looper.hpp"
|
||||
#include "lib/format-cout.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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...
|
||||
|
|
|
|||
|
|
@ -11209,8 +11209,9 @@
|
|||
<node CREATED="1481831950160" ID="ID_602481733" MODIFIED="1481831962578" TEXT="gesperrt"/>
|
||||
<node CREATED="1481831965253" ID="ID_1644273707" MODIFIED="1481832013139" TEXT="sterbend"/>
|
||||
</node>
|
||||
<node CREATED="1481831638089" ID="ID_209292609" MODIFIED="1481831840636" TEXT="Builder steuern">
|
||||
<node CREATED="1481831638089" ID="ID_209292609" MODIFIED="1482375840758" TEXT="Builder steuern">
|
||||
<arrowlink COLOR="#5242a4" DESTINATION="ID_1311208726" ENDARROW="Default" ENDINCLINATION="2;-45;" ID="Arrow_ID_313252247" STARTARROW="None" STARTINCLINATION="-186;-13;"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1481831642376" ID="ID_1301681872" MODIFIED="1481831650435" TEXT="Checkpoint bieten">
|
||||
<node CREATED="1482365008444" ID="ID_1520027430" MODIFIED="1482365011517" TEXT="wirklich">
|
||||
|
|
@ -11286,9 +11287,9 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481778708207" HGAP="48" ID="ID_1311208726" MODIFIED="1481831819823" TEXT="Builder-Steuerung" VSHIFT="-5">
|
||||
<node COLOR="#338800" CREATED="1481778708207" HGAP="48" ID="ID_1311208726" MODIFIED="1482375858816" TEXT="Builder-Steuerung" VSHIFT="-5">
|
||||
<linktarget COLOR="#5242a4" DESTINATION="ID_1311208726" ENDARROW="Default" ENDINCLINATION="2;-45;" ID="Arrow_ID_313252247" SOURCE="ID_209292609" STARTARROW="None" STARTINCLINATION="-186;-13;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1481828478741" ID="ID_1706868067" MODIFIED="1481828497838" TEXT="Hysterese"/>
|
||||
<node CREATED="1481828498618" ID="ID_321199314" MODIFIED="1481828519539" TEXT="nach neuem Command, mit kleiner Verzögerung"/>
|
||||
<node CREATED="1481828520176" ID="ID_239973202" MODIFIED="1481828532570" TEXT="bei voller Schlange mit Toleranzschwelle"/>
|
||||
|
|
@ -11298,18 +11299,24 @@
|
|||
<node CREATED="1481928867893" ID="ID_1200076817" MODIFIED="1481928871448" TEXT="wenn in Shutdown"/>
|
||||
</node>
|
||||
<node CREATED="1481928874500" ID="ID_73724471" MODIFIED="1481928881567" TEXT="idle-timeout">
|
||||
<node CREATED="1481928882723" ID="ID_770033134" MODIFIED="1481928885951" TEXT="dynamisch steuern"/>
|
||||
<node CREATED="1481928888035" ID="ID_927205346" MODIFIED="1481928912699" TEXT="kurz, wenn der Builder laufen muß"/>
|
||||
<node CREATED="1481928913687" ID="ID_696704157" MODIFIED="1481928937432" TEXT="lang sonst"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481928939300" ID="ID_1625916543" MODIFIED="1481928952211" TEXT="kein Timeout wenn gesperrt">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1481928882723" ID="ID_770033134" MODIFIED="1482375680096" TEXT="dynamisch steuern">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1481928888035" ID="ID_927205346" MODIFIED="1482375682035" TEXT="kurz, wenn der Builder laufen muß">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1481928913687" ID="ID_696704157" MODIFIED="1482375684299" TEXT="lang sonst">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1481928939300" ID="ID_1625916543" MODIFIED="1482375686245" TEXT="kein Timeout wenn gesperrt">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481928958233" ID="ID_350657817" MODIFIED="1481929002980" TEXT="Builder-Lauf erzwingen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1481928958233" ID="ID_350657817" MODIFIED="1482375661113" TEXT="Builder-Lauf erzwingen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1481928966167" ID="ID_1511723472" MODIFIED="1481928974435" TEXT="wenn lange Timeout-Spanne überschritten"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481928978223" ID="ID_106761868" MODIFIED="1482194043443" TEXT="implementierung erfordert Zeitmessung">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1481928978223" ID="ID_106761868" MODIFIED="1482375654382" TEXT="Implementierung erfordert Zeitmessung">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
</node>
|
||||
<node CREATED="1482365133332" ID="ID_99275973" MODIFIED="1482365147008" TEXT="moderne / zeitgemäße Implementierung">
|
||||
<icon BUILTIN="help"/>
|
||||
|
|
@ -11335,7 +11342,8 @@
|
|||
<node CREATED="1482202099752" ID="ID_434677221" MODIFIED="1482202114130" TEXT="geht, weil sie weiß, wann ein Command wirklich läuft"/>
|
||||
<node CREATED="1482202114630" ID="ID_1833945556" MODIFIED="1482202123872" TEXT="unschön, weil wir nun massive Kopplung haben"/>
|
||||
</node>
|
||||
<node CREATED="1482202127252" ID="ID_1720469294" MODIFIED="1482202135479" TEXT="Looper in State-machine verwandeln">
|
||||
<node CREATED="1482202127252" ID="ID_1720469294" MODIFIED="1482375697342" TEXT="Looper in State-machine verwandeln">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1482202136235" ID="ID_239151488" MODIFIED="1482202175455" TEXT="schwierig">
|
||||
<icon BUILTIN="stop-sign"/>
|
||||
</node>
|
||||
|
|
@ -11348,18 +11356,44 @@
|
|||
<node CREATED="1482202165423" ID="ID_1845799711" MODIFIED="1482202186673" TEXT="schaut sauberer aus">
|
||||
<icon BUILTIN="ksmiletris"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1482202187620" ID="ID_259250017" MODIFIED="1482202197691" TEXT="Frage: geht es überhaupt zu implementieren">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1482202187620" ID="ID_259250017" MODIFIED="1482375714962" TEXT="geht das überhaupt">
|
||||
<icon BUILTIN="help"/>
|
||||
<node CREATED="1482375716922" ID="ID_1702615812" MODIFIED="1482375756924" TEXT="ja">
|
||||
<icon BUILTIN="forward"/>
|
||||
</node>
|
||||
<node CREATED="1482375724321" ID="ID_218202011" MODIFIED="1482375736264" TEXT="einfacher trap-door-Mechanismus">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node CREATED="1482375737327" ID="ID_1980564250" MODIFIED="1482375746202" TEXT="tendentiell bereits schwer zu verstehen">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1482202207242" ID="ID_1287224856" MODIFIED="1482202269318" TEXT="Test">
|
||||
<icon BUILTIN="pencil"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1482202207242" ID="ID_1287224856" MODIFIED="1482375808494" TEXT="Test">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1482202211049" ID="ID_1159832087" MODIFIED="1482202222520" TEXT="komplexen Ablauf als Szenario durchspielen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1482202223536" ID="ID_374030732" MODIFIED="1482202266018" TEXT="Logik im Looper auf Basis generischer Überlegungen implementieren">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1482375826635" ID="ID_1275445978" MODIFIED="1482375832687" TEXT="beinhaltet auch einen Timeout">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1482202223536" ID="ID_374030732" MODIFIED="1482375796750">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Logik im Looper auf Basis
|
||||
</p>
|
||||
<p>
|
||||
generischer Überlegungen implementiert
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1482202243253" ID="ID_1342399342" MODIFIED="1482202264229" TEXT="verhält er sich dann richtig">
|
||||
<icon BUILTIN="help"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue