From 4fed0b8cd21ae14ac90045a03cd185ff951ba046 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 22 Aug 2023 18:38:40 +0200 Subject: [PATCH] Activity-Lang: clarify and fix behaviour of `POST` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...can not take a shortcut here, since the timing information embedded into the POST-Activity must somehow be transported to the Scheduler; key point to note is that the chain will be performed in »management mode« (single threaded) --- src/vault/gear/activity.hpp | 58 +++++++++++++++++--- tests/vault/gear/scheduler-activity-test.cpp | 7 ++- wiki/thinkPad.ichthyo.mm | 8 +-- 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/src/vault/gear/activity.hpp b/src/vault/gear/activity.hpp index 89910973a..f0867f2fe 100644 --- a/src/vault/gear/activity.hpp +++ b/src/vault/gear/activity.hpp @@ -33,11 +33,30 @@ ** is in processing, the corresponding descriptor data record is maintained ** by the BlockStream custom memory manager. ** - ** @note right now this is a pipe dream - ** @see ////TODO_test usage example - ** @see scheduler.cpp implementation + ** # Performing Activities ** - ** @todo WIP-WIP-WIP 6/2023 »Playback Vertical Slice« + ** The Activity data records are »POD with constructor« and can be created + ** and copied freely; the provided constructors ensure consistent setup, + ** since the meaning of the _variant data_ depends on the Activity::verb_. + ** However, in actual usage, the builder functionality of the ActivityLang + ** is used to generate linked »Activity terms«, [connecting](\ref Activity::next) + ** chains of Activities in accordance with an implicit execution protocol, which + ** also forms the base of the Activity _state machine:_ + ** - Activity::activate is invoked only once, when an Activity becomes _active._ + ** - the provided [Execution Context](\ref _verify_usable_as_ExecutionContext) + ** is connected through several λ-bindings with the actual execution logic, + ** as provided by »Layer-2« of the Scheduler + ** - Activity::dispatch is always invoked from within the scheduler and implies + ** single threaded operation with the ability to mutate the scheduler queue; + ** typically this happens after de-queuing an Activity from the priority queue + ** and leads then to Activation of the retrieved Activity; however, it can also + ** happen _right now_ -- when the indicated time has passed. + ** - Activity::notify receives a message/trigger from another prerequisite Activity + ** + ** @see SchedulerActivity_test + ** @see ActivityLang implementation of execution logic + ** + ** @todo WIP-WIP 8/2023 »Playback Vertical Slice« ** */ @@ -50,7 +69,6 @@ #include "vault/gear/job.h" #include "lib/time/timevalue.hpp" #include "lib/meta/function.hpp" -//#include "lib/symbol.hpp" #include "lib/util.hpp" //#include @@ -184,7 +202,8 @@ namespace gear { - /** + + /*********************************************//** * Term to describe an Activity, * to happen within the Scheduler's control flow. * @note Activity is a »POD with constructor« @@ -489,12 +508,18 @@ namespace gear { return activity::PASS; } + template + activity::Proc + dispatchSelf (Time when, EXE& executionCtx) + { + return executionCtx.post (when, *this, executionCtx); + } + template activity::Proc dispatchSelfDelayed (Time now, EXE& executionCtx) { - REQUIRE (next); - return executionCtx.post (executionCtx.spin(now), *this, executionCtx); + return dispatchSelf (executionCtx.spin(now), executionCtx); } template @@ -532,6 +557,21 @@ namespace gear { + /** + * @remark this defines the _Activity state machine_ and implements + * behaviour in dependency of the kind of Activity::Verb. + * Actual implementation defined effects in the Scheduler + * are abstracted as \a executionCtx: + * - `post` : dispatch the given Activity with start time + * - `work` : drop the `GroomingToken` and start processing + * - `done` : record the end time of a media computation + * - `tick` : regular maintenance hook + * @return activity::Proc indication how to proceed with execution + * - activity::PASS continue with regular processing of `next` + * - activity::SKIP ignore the rest of the chain, look for new work + * - activity::KILL abort this complete Activity term (timeout) + * - activity::HALT serious problem, stop the Scheduler + */ template activity::Proc Activity::activate (Time now, EXE& executionCtx) @@ -550,7 +590,7 @@ namespace gear { case GATE: return checkGate (now, executionCtx); case POST: - return postChain (now, executionCtx); + return dispatchSelf (now, executionCtx); case FEED: return activity::PASS; case HOOK: diff --git a/tests/vault/gear/scheduler-activity-test.cpp b/tests/vault/gear/scheduler-activity-test.cpp index 6f797282b..24089e019 100644 --- a/tests/vault/gear/scheduler-activity-test.cpp +++ b/tests/vault/gear/scheduler-activity-test.cpp @@ -109,7 +109,10 @@ namespace test { /** @test behaviour of Activity::POST - * @todo WIP 8/23 🔁 define ⟶ implement + * - invoke the λ-post to dispatch the chain through the queue + * - the chain to be executed is given as `next` + * - time window for scheduling as data field + * @todo WIP 8/23 ✔ define ✔ implement */ void verifyActivity_Post() @@ -127,7 +130,7 @@ namespace test { post.activate (tt, detector.executionCtx); cout << detector.showLog() < - - + + @@ -78639,7 +78639,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -79544,7 +79544,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- +