Activity-Lang: adaptor to watch existing Activity's activation
due to technical limitations this requires to wire the adaptor as replacement for the subject Activity, so that it can capture and log the activation, and then pass it on to its watched subject
This commit is contained in:
parent
d9f2909b07
commit
7debaaca48
7 changed files with 95 additions and 18 deletions
|
|
@ -88,7 +88,7 @@ namespace gear {
|
|||
{
|
||||
switch (verb_) {
|
||||
case INVOKE:
|
||||
return util::toString(data_.invocation.task)
|
||||
return util::showPtr (data_.invocation.task)
|
||||
+ ", "
|
||||
+ util::toString(TimeValue{data_.invocation.time});
|
||||
case WORKSTART:
|
||||
|
|
|
|||
|
|
@ -349,6 +349,9 @@ namespace gear {
|
|||
/// diagnostic representation
|
||||
operator std::string() const;
|
||||
|
||||
std::string showVerb() const;
|
||||
std::string showData() const;
|
||||
|
||||
|
||||
/********************************************************//**
|
||||
* Core Operation: _Activate_ and _perform_ this Activity.
|
||||
|
|
@ -464,10 +467,6 @@ namespace gear {
|
|||
{
|
||||
return executionCtx.tick (now);
|
||||
}
|
||||
|
||||
|
||||
std::string showVerb() const;
|
||||
std::string showData() const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ typedef lumiera_jobDescriptor* LumieraJobDescriptor;
|
|||
|
||||
#ifdef __cplusplus /* ============== C++ Interface ================= */
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
|
|
@ -207,6 +208,17 @@ namespace gear {
|
|||
{
|
||||
public:
|
||||
virtual ~JobFunctor(); ///< this is an interface
|
||||
|
||||
virtual std::string
|
||||
diagnostic() const
|
||||
{
|
||||
return "JobFunctor";
|
||||
}
|
||||
|
||||
operator std::string() const
|
||||
{
|
||||
return diagnostic();
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Interface of the closure for frame rendering jobs.
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@
|
|||
#include "vault/gear/job.h"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace vault{
|
||||
namespace gear {
|
||||
|
|
@ -65,6 +67,12 @@ namespace gear {
|
|||
return META_JOB;
|
||||
}
|
||||
|
||||
std::string
|
||||
diagnostic() const override
|
||||
{
|
||||
return "NopJobFunctor";
|
||||
}
|
||||
|
||||
InvocationInstanceID
|
||||
buildInstanceID (HashVal) const override
|
||||
{
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ namespace test {
|
|||
ActivityDetector detector;
|
||||
auto someID = "trap-" + randStr(4);
|
||||
Activity& probe = detector.buildActivationProbe (someID);
|
||||
CHECK (Activity::HOOK == probe.verb_);
|
||||
|
||||
Time realTime = RealClock::now();
|
||||
probe.activate (realTime, detector.executionCtx);
|
||||
|
|
@ -252,12 +253,43 @@ namespace test {
|
|||
|
||||
|
||||
/** @test TODO diagnostic setup to detect Activity activation and propagation
|
||||
* @todo WIP 8/23 🔁 define ⟶ implement
|
||||
* @todo WIP 8/23 ✔ define 🔁 implement
|
||||
*/
|
||||
void
|
||||
watch_activationTap()
|
||||
{
|
||||
ActivityDetector detector;
|
||||
|
||||
Time nomTime{99,11};
|
||||
Activity feed{size_t{12},size_t{34}};
|
||||
Activity feed2{size_t{56},size_t{78}};
|
||||
feed.next = &feed2;
|
||||
string jobID = "job-" + randStr(4);
|
||||
Activity invoke{detector.buildMockJobFunctor(jobID), nomTime, feed};
|
||||
|
||||
Time t1{0,1,1};
|
||||
CHECK (activity::PASS == invoke.activate (t1, detector.executionCtx));
|
||||
CHECK (detector.verifyInvocation (jobID).arg(nomTime, 12));
|
||||
|
||||
// decorate the INVOKE-Activity with an ActivationTap
|
||||
Activity& tap = detector.buildActivationTap (invoke);
|
||||
CHECK (tap.next == invoke.next);
|
||||
|
||||
++detector;
|
||||
Time t2{0,2,2};
|
||||
// now activate through the Tap....
|
||||
tap.activate(t2, detector.executionCtx);
|
||||
CHECK (detector.verifySeqIncrement(1) // ==> the ActivationTap "tap-INVOKE" reports and passes activation
|
||||
.beforeInvocation("tap-INVOKE").seq(1).arg("JobFun-ActivityDetector."+jobID)
|
||||
.beforeInvocation(jobID).seq(1).arg(nomTime,12));
|
||||
|
||||
// WARNING: can still activate the watched subject directly...
|
||||
++detector;
|
||||
Time t3{0,3,3};
|
||||
invoke.activate (t3, detector.executionCtx);
|
||||
CHECK (detector.verifyInvocation(jobID).seq(2)); // subject invoked
|
||||
CHECK (detector.ensureNoInvocation("tap-INVOKE").seq(2) // but invocation not detected by ActivationTap
|
||||
.beforeInvocation(jobID).seq(2));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -336,6 +336,11 @@ namespace test {
|
|||
mockOperation_(Time{TimeValue{param.nominalTime}}, param.invoKey.part.a);
|
||||
}
|
||||
|
||||
string diagnostic() const override
|
||||
{
|
||||
return "JobFun-"+string{mockOperation_};
|
||||
}
|
||||
|
||||
public:
|
||||
MockJobFunctor (MockOp mockedJobOperation)
|
||||
: mockOperation_{move (mockedJobOperation)}
|
||||
|
|
@ -379,11 +384,17 @@ namespace test {
|
|||
}
|
||||
|
||||
public:
|
||||
explicit
|
||||
ActivityProbe (string id, EventLog& masterLog, uint const& invocationSeqNr)
|
||||
: Activity{*this, 0}
|
||||
, log_{id, masterLog, invocationSeqNr}
|
||||
{ }
|
||||
|
||||
ActivityProbe (Activity const& subject, string id, EventLog& masterLog, uint const& invocationSeqNr)
|
||||
: Activity{*this, reinterpret_cast<size_t> (&subject)}
|
||||
, log_{id, masterLog, invocationSeqNr}
|
||||
{
|
||||
next = subject.next;
|
||||
}
|
||||
|
||||
operator string() const
|
||||
{
|
||||
|
|
@ -464,12 +475,24 @@ namespace test {
|
|||
buildDiagnosticFun<SIG_JobDiagnostic> (id));
|
||||
}
|
||||
|
||||
/** build a rigged HOOK-Activity to record each invocation */
|
||||
Activity&
|
||||
buildActivationProbe (string id)
|
||||
{
|
||||
return mockActs_.emplace_back (id, eventLog_, invocationSeq_);
|
||||
}
|
||||
|
||||
/** build ActivationProbe to record each activation before passing it to the subject */
|
||||
Activity&
|
||||
buildActivationTap (Activity const& subject, string id ="")
|
||||
{
|
||||
return mockActs_.emplace_back (subject
|
||||
,isnil(id)? "tap-"+subject.showVerb()+util::showAddr(subject)
|
||||
: id
|
||||
,eventLog_
|
||||
,invocationSeq_);
|
||||
}
|
||||
|
||||
|
||||
struct FakeExecutionCtx;
|
||||
using SIG_post = activity::Proc(Time, Activity&, FakeExecutionCtx&);
|
||||
|
|
|
|||
|
|
@ -82189,9 +82189,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node CREATED="1692372234342" ID="ID_1676209419" MODIFIED="1692372247496" TEXT="hängt über den Callback eine Log-Funktion ein"/>
|
||||
<node CREATED="1692372252979" ID="ID_473155449" MODIFIED="1692372256575" TEXT="macht aber sonst nichts"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692372261546" ID="ID_1271161818" MODIFIED="1692372266426" TEXT="als Detector-Adapter">
|
||||
<node COLOR="#338800" CREATED="1692372261546" ID="ID_1271161818" MODIFIED="1692464510720" TEXT="als Detector-Adapter">
|
||||
<arrowlink COLOR="#738eae" DESTINATION="ID_540297647" ENDARROW="Default" ENDINCLINATION="101;-5;" ID="Arrow_ID_1963690317" STARTARROW="None" STARTINCLINATION="5;52;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1692372400775" ID="ID_1270041890" MODIFIED="1692372420536" TEXT="wird dann dem Überwachungsgegenstand vorgeschaltet"/>
|
||||
<node CREATED="1692372433498" ID="ID_1038407160" MODIFIED="1692372443405" TEXT="übernimmt (doppelt) auch dessen next-Pointer"/>
|
||||
<node CREATED="1692372445273" ID="ID_1169755490" MODIFIED="1692372481928" TEXT="reicht Aktivierung an die überwachte Activity weiter"/>
|
||||
|
|
@ -82202,12 +82202,12 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node COLOR="#435e98" CREATED="1692380099390" ID="ID_851484000" MODIFIED="1692404522200" TEXT="soll die angegebene ID mit ausgeben">
|
||||
<icon BUILTIN="yes"/>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1692380024576" ID="ID_1476915138" MODIFIED="1692404468016" TEXT="custom string-conv wird nicht aufgerufen">
|
||||
<node COLOR="#435e98" CREATED="1692380024576" FOLDED="true" ID="ID_1476915138" MODIFIED="1692464519801" TEXT="custom string-conv wird nicht aufgerufen">
|
||||
<icon BUILTIN="broken-line"/>
|
||||
<node CREATED="1692380071745" ID="ID_708893412" MODIFIED="1692404214990" TEXT="offensichtlicher Grund: es ist ein Pointer">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node COLOR="#5b280f" CREATED="1692404216754" ID="ID_1806024569" MODIFIED="1692404238247" TEXT="util::toString sollte sich bei Pointern sinnvoll verhalten">
|
||||
<node COLOR="#5b280f" CREATED="1692404216754" FOLDED="true" ID="ID_1806024569" MODIFIED="1692404238247" TEXT="util::toString sollte sich bei Pointern sinnvoll verhalten">
|
||||
<icon BUILTIN="button_cancel"/>
|
||||
<node COLOR="#5b280f" CREATED="1692404252108" ID="ID_842776495" MODIFIED="1692404264513" TEXT="versucht und gescheitert">
|
||||
<icon BUILTIN="stop-sign"/>
|
||||
|
|
@ -82240,16 +82240,19 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205295574" ID="ID_1666280196" MODIFIED="1689205299838" TEXT="activationTap">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692459867253" ID="ID_1660140905" MODIFIED="1692459954104" TEXT="ist implementiert als activationProbe">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1689205295574" ID="ID_1666280196" MODIFIED="1692464467352" TEXT="activationTap">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1692459867253" ID="ID_1660140905" MODIFIED="1692464463174" TEXT="ist implementiert als activationProbe">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692459877082" ID="ID_540297647" MODIFIED="1692459982782" TEXT="aber wird als Adapter vor eine gegebene Activity geschaltet">
|
||||
<node COLOR="#338800" CREATED="1692459877082" ID="ID_540297647" MODIFIED="1692464463949" TEXT="aber wird als Adapter vor eine gegebene Activity geschaltet">
|
||||
<linktarget COLOR="#738eae" DESTINATION="ID_540297647" ENDARROW="Default" ENDINCLINATION="101;-5;" ID="Arrow_ID_1963690317" SOURCE="ID_1271161818" STARTARROW="None" STARTINCLINATION="5;52;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692459890448" ID="ID_42862803" MODIFIED="1692459954106" TEXT="übernimmt von dieser eine default-ID und den next-Ptr">
|
||||
<node COLOR="#338800" CREATED="1692459890448" ID="ID_42862803" MODIFIED="1692464464796" TEXT="übernimmt von dieser eine default-ID und den next-Ptr">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692464468863" ID="ID_1403493828" MODIFIED="1692464498932" TEXT="Variante: manipuliert/dekoriert direkt einen Activity-Ptr">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue