Activity-Lang: clarify and fix behaviour of POST

...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)
This commit is contained in:
Fischlurch 2023-08-22 18:38:40 +02:00
parent 4c0e58849a
commit 4fed0b8cd2
3 changed files with 58 additions and 15 deletions

View file

@ -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 <string>
@ -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<class EXE>
activity::Proc
dispatchSelf (Time when, EXE& executionCtx)
{
return executionCtx.post (when, *this, executionCtx);
}
template<class EXE>
activity::Proc
dispatchSelfDelayed (Time now, EXE& executionCtx)
{
REQUIRE (next);
return executionCtx.post (executionCtx.spin(now), *this, executionCtx);
return dispatchSelf (executionCtx.spin(now), executionCtx);
}
template<class EXE>
@ -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<class EXE>
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:

View file

@ -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() <<endl;
CHECK (detector.verifyInvocation("CTX-post").arg("11.011", "Act(TICK", "≺test::CTX≻")); ///////////////////OOO need somehow to transport the time window...
CHECK (detector.verifyInvocation("CTX-post").arg("11.011", "Act(POST", "≺test::CTX≻"));
}

View file

@ -78534,8 +78534,8 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<linktarget COLOR="#8897a9" DESTINATION="ID_817512371" ENDARROW="Default" ENDINCLINATION="-175;61;" ID="Arrow_ID_847368059" SOURCE="ID_681493814" STARTARROW="None" STARTINCLINATION="-262;0;"/>
<node CREATED="1692569081906" ID="ID_914571375" MODIFIED="1692569093021" TEXT="versucht das Grooming-Token zu erlangen"/>
<node CREATED="1692569093561" ID="ID_1575390199" MODIFIED="1692569104579" TEXT="sonst: Dispatch &#xfc;ber die Queue"/>
<node CREATED="1692569105461" ID="ID_1960608539" MODIFIED="1692569164192" TEXT="schlie&#xdf;lich Dispatch auf der konkreten Activity">
<arrowlink COLOR="#46429b" DESTINATION="ID_1729670913" ENDARROW="Default" ENDINCLINATION="100;-277;" ID="Arrow_ID_1325928186" STARTARROW="None" STARTINCLINATION="-484;32;"/>
<node CREATED="1692569105461" ID="ID_1960608539" MODIFIED="1692722072608" TEXT="schlie&#xdf;lich Dispatch &#x27f9; Aktivierung der Chain-Activity">
<arrowlink COLOR="#46429b" DESTINATION="ID_1729670913" ENDARROW="Default" ENDINCLINATION="100;-277;" ID="Arrow_ID_1325928186" STARTARROW="None" STARTINCLINATION="-479;27;"/>
</node>
</node>
</node>
@ -78639,7 +78639,7 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
</node>
<node COLOR="#338800" CREATED="1690068951061" ID="ID_1729670913" MODIFIED="1692634844170" TEXT="Dispatch">
<linktarget COLOR="#46429b" DESTINATION="ID_1729670913" ENDARROW="Default" ENDINCLINATION="100;-277;" ID="Arrow_ID_1325928186" SOURCE="ID_1960608539" STARTARROW="None" STARTINCLINATION="-484;32;"/>
<linktarget COLOR="#46429b" DESTINATION="ID_1729670913" ENDARROW="Default" ENDINCLINATION="100;-277;" ID="Arrow_ID_1325928186" SOURCE="ID_1960608539" STARTARROW="None" STARTINCLINATION="-479;27;"/>
<icon BUILTIN="button_ok"/>
<node CREATED="1692567620559" ID="ID_560161359" MODIFIED="1692567640105" TEXT="Notification indirekt &#xfc;ber den Scheduler">
<icon BUILTIN="info"/>
@ -79544,7 +79544,7 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
<node COLOR="#338800" CREATED="1692718407577" ID="ID_500127760" MODIFIED="1692718464799" TEXT="verifyActivity_Post">
<icon BUILTIN="button_ok"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692718467475" HGAP="25" ID="ID_1128481830" MODIFIED="1692718501944" TEXT="POST mu&#xdf; die Zeitfenster-Info transportieren" VSHIFT="5">
<node COLOR="#435e98" CREATED="1692718467475" HGAP="25" ID="ID_1128481830" MODIFIED="1692722002808" TEXT="POST mu&#xdf; die Zeitfenster-Info transportieren" VSHIFT="5">
<icon BUILTIN="broken-line"/>
</node>
</node>