Activity-Lang: framework to execute a chain of Activities
without and error or concurrency handling (which is the responsibility of the Scheduler-Layer-2; just the sequencing of individual activations
This commit is contained in:
parent
2746743135
commit
900f46b1d5
5 changed files with 112 additions and 4 deletions
|
|
@ -87,6 +87,39 @@ namespace gear {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execution Framework: dispatch performance of a chain of Activities.
|
||||
*/
|
||||
template<class EXE>
|
||||
static activity::Proc
|
||||
dispatchChain (Activity& chain, Time now, EXE& executionCtx)
|
||||
{
|
||||
activity::Proc res = chain.dispatch (now, executionCtx);
|
||||
if (activity::PASS == res)
|
||||
res = activateChain (chain.next, now, executionCtx);
|
||||
else if (activity::SKIP == res)
|
||||
res = activity::PASS;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execution Framework: successive activation of Activities in a chain.
|
||||
*/
|
||||
template<class EXE>
|
||||
static activity::Proc
|
||||
activateChain (Activity* chain, Time now, EXE& executionCtx)
|
||||
{
|
||||
activity::Proc res{activity::PASS};
|
||||
while (chain and activity::PASS == res)
|
||||
{
|
||||
res = chain->activate (now, executionCtx);
|
||||
chain = chain->next;
|
||||
}
|
||||
if (activity::SKIP == res)// SKIP has been handled
|
||||
res = activity::PASS; // just by aborting the loop
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
/** @internal generate the builder / configurator term */
|
||||
activity::Term
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@ namespace gear {
|
|||
bool isDead (Time now) const { return dead <= now;}
|
||||
bool isHold () const { return rest > 0; }
|
||||
bool isFree (Time now) const { return not (isHold() or isDead(now)); }
|
||||
void incDependencies() { ++rest; }
|
||||
};
|
||||
|
||||
/** Time window to define for activation */
|
||||
|
|
@ -614,7 +615,7 @@ namespace gear {
|
|||
* a `POST`-Activity. Control flow passing here has acquired the `GroomingToken`
|
||||
* and can thus assume single threaded execution until `WORKSTART`.
|
||||
* @note special twist for the `NOTIFY`-Activity: it is not _activated_
|
||||
* itself, rather the #notify operation is invoked on its target(`next`);
|
||||
* itself, rather the #notify operation is invoked on its target argument;
|
||||
* this is necessary since a notification passes control-flow outside
|
||||
* the regular linear `next`-chain; when a `NOTIFY` is _activated,_
|
||||
* it will `post()` itself to acquire the `GroomingToken` and then
|
||||
|
|
|
|||
|
|
@ -542,7 +542,7 @@ namespace test {
|
|||
Activity&
|
||||
buildGateWatcher (Activity& gate, string id ="")
|
||||
{
|
||||
insertActivationTap (gate.next, "after" + (isnil(id)? gate.showVerb()+util::showAddr(gate) : id));
|
||||
insertActivationTap (gate.next, "after-" + (isnil(id)? gate.showVerb()+util::showAddr(gate) : id));
|
||||
return buildActivationTap (gate, id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ namespace test {
|
|||
verifyActivity_Gate_opened();
|
||||
|
||||
termBuilder();
|
||||
dispatchChain();
|
||||
|
||||
scenario_RenderJob();
|
||||
scenario_IOJob();
|
||||
|
|
@ -322,7 +323,7 @@ namespace test {
|
|||
CHECK (detector.verifyInvocation("tap-GATE").seq(0).arg("33.333 ⧐ Act(GATE")
|
||||
.beforeInvocation("CTX-post").seq(0).arg(reScheduled, "Act(GATE", "≺test::CTX≻")
|
||||
.beforeInvocation("tap-GATE").seq(1).arg("33.333 --notify-↯> Act(GATE")
|
||||
.beforeInvocation("CTX-post").seq(1).arg(tt, "afterGATE", "≺test::CTX≻"));
|
||||
.beforeInvocation("CTX-post").seq(1).arg(tt, "after-GATE", "≺test::CTX≻"));
|
||||
CHECK (gate.data_.condition.dead == Time::MIN);
|
||||
|
||||
detector.incrementSeq();
|
||||
|
|
@ -342,7 +343,7 @@ namespace test {
|
|||
// the log shows the further notification (at Seq=3) but no dispatch happens anymore
|
||||
CHECK (detector.verifySeqIncrement(3)
|
||||
.beforeInvocation("tap-GATE").seq(3).arg("44.444 --notify-↯> Act(GATE"));
|
||||
CHECK (detector.ensureNoInvocation("CTX-post").seq(3).arg(tt, "afterGATE", "≺test::CTX≻"));
|
||||
CHECK (detector.ensureNoInvocation("CTX-post").seq(3).arg(tt, "after-GATE", "≺test::CTX≻"));
|
||||
|
||||
// cout << detector.showLog()<<endl; // HINT: use this for investigation...
|
||||
}
|
||||
|
|
@ -399,6 +400,33 @@ namespace test {
|
|||
|
||||
|
||||
|
||||
/** @test verify the ability to _dispatch and perform_ a chain of activities.
|
||||
* - use a directly wired, arbitrary chain
|
||||
* - dispatch will activate all Activities
|
||||
* @todo WIP 8/23 🔁 define ⟶ implement
|
||||
*/
|
||||
void
|
||||
dispatchChain()
|
||||
{
|
||||
Time tt{11,1};
|
||||
Activity tick;
|
||||
Activity gate{0};
|
||||
gate.next = &tick;
|
||||
Activity post{tt, &gate};
|
||||
// so now we have POST ⟶ GATE ⟶ TICK;
|
||||
|
||||
ActivityDetector detector;
|
||||
// insert instrumentation to trace activation
|
||||
detector.watchGate (post.next, "Gate");
|
||||
|
||||
CHECK (activity::PASS == ActivityLang::dispatchChain (post, tt, detector.executionCtx));
|
||||
|
||||
cout << detector.showLog()<<endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** @test TODO usage scenario: Activity graph for a render job
|
||||
* @todo WIP 8/23 🔁 define ⟶ implement
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78066,6 +78066,40 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node CREATED="1693317661471" ID="ID_709533668" MODIFIED="1693317672145" TEXT="es wird stets der nächst greifbare Parameter verwendet"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1693345571268" ID="ID_1280713523" MODIFIED="1693345593849" TEXT="Ausführung einer Kette">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1693345578139" ID="ID_1743236034" MODIFIED="1693345586916" TEXT="realisiert in Activity-Lang">
|
||||
<icon BUILTIN="info"/>
|
||||
</node>
|
||||
<node CREATED="1693426529370" ID="ID_1866137109" MODIFIED="1693426556041" TEXT="einfache Schleife bis Kettenende bzw. != PASS">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node CREATED="1693426559375" ID="ID_728243970" MODIFIED="1693426583903" TEXT="dispatchChain() : Einstieg über dispatch(), dann activateChain()"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1693345602461" ID="ID_996451340" MODIFIED="1693345626237" TEXT="Dispatch">
|
||||
<icon BUILTIN="hourglass"/>
|
||||
<node CREATED="1693345606503" ID="ID_1448505632" MODIFIED="1693345622980" TEXT="realisiert im Scheduler-Commutator (Layer-2)">
|
||||
<icon BUILTIN="info"/>
|
||||
</node>
|
||||
<node CREATED="1693345633335" ID="ID_184362197" MODIFIED="1693345658139">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Verwaltung des <b>GroomingToken</b>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="forward"/>
|
||||
</node>
|
||||
<node CREATED="1693345687956" ID="ID_885356569" MODIFIED="1693345702766" TEXT="post() ≡ Eingangsverzweigung">
|
||||
<node CREATED="1693345771969" ID="ID_120381746" MODIFIED="1693345804830" TEXT="GroomingToken erlangt ⟹ Einstieg dispatch()"/>
|
||||
<node CREATED="1693345805685" ID="ID_941490506" MODIFIED="1693345824878" TEXT="sonst ⟹ Dispatch-Queue"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690068830605" ID="ID_330404913" MODIFIED="1692567498691" TEXT="Activation">
|
||||
|
|
@ -79973,6 +80007,18 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1693426627134" ID="ID_468206154" MODIFIED="1693426685918" TEXT="dispatchChain">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1693426634246" ID="ID_1750182879" MODIFIED="1693426683358" TEXT="testet die Ausführungs-Funktion in ActivityLang">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1693426656634" ID="ID_965537081" MODIFIED="1693426681870" TEXT="verwendet eine künstliche, direkt verdrahtete Kette">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1693426668288" ID="ID_1618574447" MODIFIED="1693426678575" TEXT="Abbruch bei SKIP">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689200553782" ID="ID_472609287" MODIFIED="1689200578260" TEXT="scenario_RenderJob">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1693323299522" ID="ID_1282022548" MODIFIED="1693323306513" TEXT="Grundstruktur verdrahten">
|
||||
|
|
|
|||
Loading…
Reference in a new issue