Activity-Lang: build activation detector

...using a HOOK-Activity as prepended adaptor,
optionally forwarding the activation to the inferior
This commit is contained in:
Fischlurch 2023-08-18 19:37:44 +02:00
parent 9cdfdf3d18
commit 3784bd7252
4 changed files with 118 additions and 4 deletions

View file

@ -136,6 +136,17 @@ namespace gear {
virtual Proc activation ( Activity& thisHook
, Time now
, void* executionCtx) =0;
virtual std::string
diagnostic() const
{
return "Activity::Hook";
}
operator std::string() const
{
return diagnostic();
}
};

View file

@ -29,7 +29,7 @@
#include "activity-detector.hpp"
#include "lib/test/test-helper.hpp"
#include "lib/time/timevalue.hpp"
#include "lib/format-cout.hpp"
#include "lib/format-cout.hpp" /////////////////////////////TODO
//#include "lib/util.hpp"
//#include <utility>
@ -39,6 +39,8 @@
//using lib::time::FSecs;
//using std::move;
//using util::isSameObject;
using lib::test::randStr;
using lib::test::randTime;
namespace vault{
@ -193,7 +195,7 @@ namespace test {
// an otherwise opaque object fulfilling the "Concept"
activity::_verify_usable_as_ExecutionContext<decltype(detector.executionCtx)>();
Time t = lib::test::randTime();
Time t = randTime();
size_t x = rand();
Activity a;
@ -229,11 +231,15 @@ 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
detect_activation()
{
auto someID = "trap-" + randStr(4);
ActivityDetector detector;
Activity& probe = detector.buildActivationProbe (someID);
cout << probe << endl;
}

View file

@ -285,6 +285,8 @@ namespace test {
return std::move (*this);
}
// default copyable
/** mock function call operator: logs all invocations */
RET
operator() (ARGS ...args)
@ -293,6 +295,11 @@ namespace test {
.addAttrib (MARK_SEQ, util::toString(*seqNr_));
return *retVal_;
}
operator string() const
{
return log_->getID()+"."+id_;
}
};
/** @internal type rebinding helper */
@ -307,6 +314,8 @@ namespace test {
using Type = typename RebindVariadic<DiagnosticFun, SigTypes>::Type;
};
using Logger = _DiagnosticFun<void(string)>::Type;
/**
* A Mocked job operation to detect any actual invocation
@ -334,9 +343,59 @@ namespace test {
};
/**
* A rigged CALLBACK-Activity to watch passing of activations.
*/
class ActivityProbe
: public Activity
, activity::Hook
{
Logger log_;
activity::Proc
activation ( Activity& thisHook
, Time now
, void* executionCtx) override
{
REQUIRE (Activity::HOOK == thisHook.verb_);
if (data_.callback.arg == 0)
{// no adapted target; just record this activation
log_(util::toString(now) + "");
return activity::PASS;
}
else
{// forward activation to the adapted target Activity
Activity& target = *reinterpret_cast<Activity*> (data_.callback.arg);
auto ctx = *static_cast<FakeExecutionCtx*> (executionCtx);
log_(util::toString(now) + "" + util::toString (target));
return target.activate (now, ctx);
}
}
std::string
diagnostic() const override
{
return "Probe("+string{log_}+")";
}
public:
explicit
ActivityProbe (string id, EventLog& masterLog, uint const& invocationSeqNr)
: Activity{*this, 0}
, log_{id, masterLog, invocationSeqNr}
{ }
operator string() const
{
return diagnostic();
}
};
/* ===== Maintain throw-away mock instances ===== */
std::deque<MockJobFunctor> mockOps_{};
std::deque<ActivityProbe> mockActs_{};
public:
@ -405,6 +464,11 @@ namespace test {
buildDiagnosticFun<SIG_JobDiagnostic> (id));
}
Activity&
buildActivationProbe (string id)
{
return mockActs_.emplace_back (id, eventLog_, invocationSeq_);
}
struct FakeExecutionCtx;

View file

@ -82173,8 +82173,41 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<icon BUILTIN="help"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205263970" ID="ID_43321196" MODIFIED="1689205277049" TEXT="activationProbe">
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1689205263970" ID="ID_43321196" MODIFIED="1692372280856" TEXT="activationProbe">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1692372010821" ID="ID_607483737" MODIFIED="1692380006038" TEXT="ist zugleich CALLBACK-Activity und Adapter">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1692372106295" ID="ID_1204006498" MODIFIED="1692372277279" TEXT="wird intern vom ActivityDetector verwaltet">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1692372170118" ID="ID_1107069049" MODIFIED="1692372271039" TEXT="verschiedene Verdrahtungs-M&#xf6;glichkeiten">
<icon BUILTIN="forward"/>
<node COLOR="#338800" CREATED="1692372197889" ID="ID_1824930461" MODIFIED="1692379992948" TEXT="als reine Detector-Activity">
<icon BUILTIN="button_ok"/>
<node CREATED="1692372210456" ID="ID_1081495304" MODIFIED="1692372233546" TEXT="lediglich als Activity&amp; zu verwenden"/>
<node CREATED="1692372234342" ID="ID_1676209419" MODIFIED="1692372247496" TEXT="h&#xe4;ngt &#xfc;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">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1692372400775" ID="ID_1270041890" MODIFIED="1692372420536" TEXT="wird dann dem &#xdc;berwachungsgegenstand vorgeschaltet"/>
<node CREATED="1692372433498" ID="ID_1038407160" MODIFIED="1692372443405" TEXT="&#xfc;bernimmt (doppelt) auch dessen next-Pointer"/>
<node CREATED="1692372445273" ID="ID_1169755490" MODIFIED="1692372481928" TEXT="reicht Aktivierung an die &#xfc;berwachte Activity weiter"/>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1692380008794" ID="ID_1667310608" MODIFIED="1692380053308" TEXT="diagnostic / toString">
<icon BUILTIN="pencil"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692380099390" ID="ID_851484000" MODIFIED="1692380120878" TEXT="soll die angegebene ID mit ausgeben">
<icon BUILTIN="yes"/>
</node>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1692380024576" ID="ID_1476915138" MODIFIED="1692380051034" TEXT="custom string-conv wird nicht aufgerufen">
<icon BUILTIN="broken-line"/>
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1692380071745" ID="ID_708893412" MODIFIED="1692380087144" TEXT="das enable_if greift nicht... warum?">
<icon BUILTIN="help"/>
</node>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205295574" ID="ID_1666280196" MODIFIED="1689205299838" TEXT="activationTap">
<icon BUILTIN="flag-yellow"/>