From 900f46b1d5bbd461ec058e574ad32ba1e66d134f Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 30 Aug 2023 22:19:57 +0200 Subject: [PATCH] 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 --- src/vault/gear/activity-lang.hpp | 33 ++++++++++++++ src/vault/gear/activity.hpp | 3 +- tests/vault/gear/activity-detector.hpp | 2 +- tests/vault/gear/scheduler-activity-test.cpp | 32 +++++++++++++- wiki/thinkPad.ichthyo.mm | 46 ++++++++++++++++++++ 5 files changed, 112 insertions(+), 4 deletions(-) diff --git a/src/vault/gear/activity-lang.hpp b/src/vault/gear/activity-lang.hpp index cd0549e33..3080fb8dd 100644 --- a/src/vault/gear/activity-lang.hpp +++ b/src/vault/gear/activity-lang.hpp @@ -87,6 +87,39 @@ namespace gear { } + /** + * Execution Framework: dispatch performance of a chain of Activities. + */ + template + 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 + 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 diff --git a/src/vault/gear/activity.hpp b/src/vault/gear/activity.hpp index 885d68c5e..f84e7fed9 100644 --- a/src/vault/gear/activity.hpp +++ b/src/vault/gear/activity.hpp @@ -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 diff --git a/tests/vault/gear/activity-detector.hpp b/tests/vault/gear/activity-detector.hpp index d4b79dab5..320402963 100644 --- a/tests/vault/gear/activity-detector.hpp +++ b/tests/vault/gear/activity-detector.hpp @@ -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); } diff --git a/tests/vault/gear/scheduler-activity-test.cpp b/tests/vault/gear/scheduler-activity-test.cpp index 812efbced..41494a140 100644 --- a/tests/vault/gear/scheduler-activity-test.cpp +++ b/tests/vault/gear/scheduler-activity-test.cpp @@ -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()< + + + + + + + + + + + + + + + + + + + + + +

+ Verwaltung des GroomingToken +

+ + +
+ +
+ + + + +
@@ -79973,6 +80007,18 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + + + + + +