Activity-Lang: introduce a callback hook
...primarily intended for testing, but could be helpful as generic extension point later on...
This commit is contained in:
parent
49f2e34e4c
commit
111c05a1f9
4 changed files with 99 additions and 2 deletions
|
|
@ -110,6 +110,35 @@ namespace gear {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Extension point to invoke a callback from Activity activation
|
||||
* @remark referred from the Activity::Verb::HOOK
|
||||
* @see ActivityDetector primary usage for testing
|
||||
*/
|
||||
class Hook
|
||||
{
|
||||
public:
|
||||
virtual ~Hook(); ///< this is an interface
|
||||
|
||||
/**
|
||||
* Callback on activation of the corresponding HOOK-Activity.
|
||||
* @param thisHook the Activity record wired to this hook
|
||||
* @param executionCtx opaque pointer to the actual execution context
|
||||
* @param now current »wall-clock-time« as used by the Scheduler
|
||||
* @return decision how to proceed with the activation
|
||||
* @remark the intended use is to rig this callback based on additional knowledge
|
||||
* regarding the usage context. Through \a thisHook, the follow-up chain
|
||||
* is accessible, and an additional payload data field (`size_t`). Since
|
||||
* the execution context is a _concept,_ it is necessary to know the actual
|
||||
* type of the concrete execution context and cast down in the implementation.
|
||||
* This mechanism is used especially for detecting expected test invocations.
|
||||
*/
|
||||
virtual Proc activation ( Activity& thisHook
|
||||
, void* executionCtx
|
||||
, Time now) =0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Definition to emulate a _Concept_ for the *Execution Context*.
|
||||
* The Execution Context need to be passed to any Activity _activation;_
|
||||
|
|
@ -161,6 +190,7 @@ namespace gear {
|
|||
,GATE ///< probe window + count-down; activate next Activity, else re-schedule
|
||||
,POST ///< post a message providing a chain of further time-bound Activities
|
||||
,FEED ///< supply additional payload data for a preceding Activity
|
||||
,HOOK ///< invoke an _extension point_ through the activity::Hook interface
|
||||
,TICK ///< internal engine »heart beat« for internal maintenance hook(s)
|
||||
};
|
||||
|
||||
|
|
@ -189,6 +219,13 @@ namespace gear {
|
|||
size_t quality;
|
||||
};
|
||||
|
||||
/** Extension point to invoke */
|
||||
struct Callback
|
||||
{
|
||||
activity::Hook* hook;
|
||||
size_t arg;
|
||||
};
|
||||
|
||||
/** Access gate condition to evaluate */
|
||||
struct Condition
|
||||
{
|
||||
|
|
@ -223,6 +260,7 @@ namespace gear {
|
|||
{
|
||||
Feed feed;
|
||||
Timing timing;
|
||||
Callback callback;
|
||||
Condition condition;
|
||||
TimeWindow timeWindow;
|
||||
Invocation invocation;
|
||||
|
|
@ -251,6 +289,14 @@ namespace gear {
|
|||
data_.feed.two = o2;
|
||||
}
|
||||
|
||||
Activity (JobFunctor& job, Time nominalTime, Activity& feed) noexcept
|
||||
: Activity{INVOKE}
|
||||
{
|
||||
data_.invocation.task = &job;
|
||||
data_.invocation.time = nominalTime;
|
||||
next = &feed;
|
||||
}
|
||||
|
||||
explicit
|
||||
Activity (Activity* target) noexcept
|
||||
: Activity{NOTIFY}
|
||||
|
|
@ -280,6 +326,13 @@ namespace gear {
|
|||
data_.timeWindow = {start,after};
|
||||
}
|
||||
|
||||
Activity (activity::Hook& callback, size_t arg) noexcept
|
||||
: Activity{HOOK}
|
||||
{
|
||||
data_.callback.hook = &callback;
|
||||
data_.callback.arg = arg;
|
||||
}
|
||||
|
||||
Activity() noexcept
|
||||
: Activity{TICK}
|
||||
{ }
|
||||
|
|
@ -385,6 +438,14 @@ namespace gear {
|
|||
return executionCtx.post (*next, executionCtx, now);
|
||||
}
|
||||
|
||||
template<class EXE>
|
||||
activity::Proc
|
||||
callHook (EXE& executionCtx, Time now)
|
||||
{
|
||||
return data_.callback.hook? data_.callback.hook->activation(*this, &executionCtx, now)
|
||||
: activity::PASS;
|
||||
}
|
||||
|
||||
template<class EXE>
|
||||
activity::Proc
|
||||
doTick (EXE& executionCtx, Time now)
|
||||
|
|
@ -417,6 +478,8 @@ namespace gear {
|
|||
return postChain (executionCtx, now);
|
||||
case FEED:
|
||||
return activity::PASS;
|
||||
case HOOK:
|
||||
return callHook (executionCtx, now);
|
||||
case TICK:
|
||||
return doTick (executionCtx, now);
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -52,7 +52,10 @@ namespace gear {
|
|||
|
||||
} // internal details
|
||||
|
||||
|
||||
namespace activity {
|
||||
|
||||
Hook::~Hook() { } // emit VTable here...
|
||||
}
|
||||
|
||||
// NA::~NA() { }
|
||||
|
||||
|
|
|
|||
|
|
@ -6858,7 +6858,7 @@ At first sight the link between asset and clip-MO is a simple logical relation b
|
|||
|
||||
{{red{Note 1/2015}}} several aspects regarding the relation of clips and single/multichannel media are not yet settled. There is a preliminary implementation in the code base, but it is not sure yet how multichnnel media will actually be modelled. Currently, we tend to treat the channel multiplicity rather as a property of the involved media, i.e we have //one// clip object.</pre>
|
||||
</div>
|
||||
<div title="RenderActivity" creator="Ichthyostega" modifier="Ichthyostega" created="202304140145" modified="202307301650" tags="Rendering spec draft" changecount="13">
|
||||
<div title="RenderActivity" creator="Ichthyostega" modifier="Ichthyostega" created="202304140145" modified="202308011337" tags="Rendering spec draft" changecount="14">
|
||||
<pre>//Render Activities define the execution language of the render engine.//
|
||||
The [[Scheduler]] maintains the ability to perform these Activities, in a time-bound fashion, observing dependency relations; activities allow for notification of completed work, tracking of dependencies, timing measurements, re-scheduling of other activities -- and last but not least the dispatch of actual [[render jobs|RenderJob]]. Activities are what is actually enqueued with priority in the scheduler implementation, they are planned for a »µ-tick slot«, activated once when the activation time is reached, and then forgotten. Each Activity is a //verb//, but can be inhibited by conditions and carry operation object data. Formally, activating an Activity equates to a predication, and the subject of that utterance is »the render process«.
|
||||
|
||||
|
|
@ -6878,6 +6878,8 @@ The [[Scheduler]] maintains the ability to perform these Activities, in a time-b
|
|||
:supply additional payload data for a preceding Activity
|
||||
;post
|
||||
:post a message providing a chain of further time-bound Activities
|
||||
;hook
|
||||
:invoke a callback, passing invocation information. Intended for testing.
|
||||
;tick
|
||||
:internal engine »heart beat« -- invoke internal maintenance hook(s)
|
||||
|
||||
|
|
|
|||
|
|
@ -78074,6 +78074,13 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node CREATED="1688601991523" ID="ID_1519691813" MODIFIED="1688602001213" TEXT="deadline"/>
|
||||
<node CREATED="1688602002513" ID="ID_1687808112" MODIFIED="1688602012044" TEXT="counter"/>
|
||||
</node>
|
||||
<node CREATED="1690891793894" ID="ID_38417195" LINK="#ID_1359624247" MODIFIED="1690891968992" TEXT="hook">
|
||||
<node COLOR="#435e98" CREATED="1690891815995" ID="ID_163409040" MODIFIED="1690896708168" TEXT="Interface activity::Hook">
|
||||
<arrowlink COLOR="#6b779d" DESTINATION="ID_1359624247" ENDARROW="Default" ENDINCLINATION="683;-50;" ID="Arrow_ID_1699110020" STARTARROW="None" STARTINCLINATION="2539;289;"/>
|
||||
<icon BUILTIN="info"/>
|
||||
</node>
|
||||
<node CREATED="1690892071722" ID="ID_1987094589" MODIFIED="1690892077037" TEXT="zusätzliches Payload-Feld"/>
|
||||
</node>
|
||||
<node CREATED="1688603899403" ID="ID_1940894045" MODIFIED="1688603926576" TEXT="post">
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1688604029521" ID="ID_1078704694" MODIFIED="1688693453667" TEXT="transportiert kontextuelle Info (time window)">
|
||||
<icon BUILTIN="idea"/>
|
||||
|
|
@ -78597,6 +78604,13 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1690891900488" ID="ID_955220405" MODIFIED="1690891904780" TEXT="HOOK">
|
||||
<node CREATED="1690891815995" ID="ID_642006957" MODIFIED="1690891938727" TEXT="als Erweiterungspunkt / für Instrumentierung">
|
||||
<arrowlink COLOR="#759db4" DESTINATION="ID_1359624247" ENDARROW="Default" ENDINCLINATION="446;-43;" ID="Arrow_ID_265182299" STARTARROW="None" STARTINCLINATION="1008;65;"/>
|
||||
</node>
|
||||
<node CREATED="1690892152761" ID="ID_1147906730" MODIFIED="1690892165928" TEXT="ruft den Erweiterungspunkt auf (virtual call)"/>
|
||||
<node CREATED="1690892167303" ID="ID_439509474" MODIFIED="1690892177400" TEXT="übergibt ExecutionCtx + this"/>
|
||||
</node>
|
||||
<node CREATED="1690069195852" ID="ID_1205140605" MODIFIED="1690069197272" TEXT="TICK">
|
||||
<node CREATED="1690069554609" ID="ID_250578152" MODIFIED="1690069556663" TEXT="λ-tick"/>
|
||||
</node>
|
||||
|
|
@ -81684,6 +81698,21 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690891585410" ID="ID_1976653650" MODIFIED="1690891593537" TEXT="Action-Hook">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690891602401" ID="ID_1359624247" MODIFIED="1690896708168" TEXT="als Primitive einführen">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
<p>
|
||||
...auch wenn's bisher bloß der Test-Unterstützung dient, es ist in jedem Fall gerechtfertigt, einen generischen Erweiterungspunkt zu haben
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<linktarget COLOR="#6b779d" DESTINATION="ID_1359624247" ENDARROW="Default" ENDINCLINATION="683;-50;" ID="Arrow_ID_1699110020" SOURCE="ID_163409040" STARTARROW="None" STARTINCLINATION="2539;289;"/>
|
||||
<linktarget COLOR="#759db4" DESTINATION="ID_1359624247" ENDARROW="Default" ENDINCLINATION="446;-43;" ID="Arrow_ID_265182299" SOURCE="ID_642006957" STARTARROW="None" STARTINCLINATION="1008;65;"/>
|
||||
<icon BUILTIN="yes"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205029658" ID="ID_1144318045" MODIFIED="1689205033146" TEXT="Verifikationen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue