diff --git a/src/vault/gear/scheduler-commutator.hpp b/src/vault/gear/scheduler-commutator.hpp
index 73a2ea3c8..12cc0379a 100644
--- a/src/vault/gear/scheduler-commutator.hpp
+++ b/src/vault/gear/scheduler-commutator.hpp
@@ -40,6 +40,7 @@
#include "vault/common.hpp"
#include "vault/gear/activity.hpp"
#include "vault/gear/scheduler-invocation.hpp"
+#include "vault/gear/activity-lang.hpp"
#include "lib/time/timevalue.hpp"
#include "lib/nocopy.hpp"
@@ -183,7 +184,17 @@ namespace gear {
,EXE& executionCtx
,SchedulerInvocation& layer1)
{
- UNIMPLEMENTED ("core function: maybe perform activity");
+ if (!chain) return activity::WAIT;
+
+ Time now = executionCtx.getSchedTime();
+ if (decideDispatchNow (when, now))
+ return ActivityLang::dispatchChain (*chain, executionCtx);
+ else
+ if (holdsGroomingToken(std::this_thread::get_id()))
+ layer1.feedPrioritisation (*chain, when);
+ else
+ layer1.instruct (*chain, when);
+ return activity::PASS;
}
};
diff --git a/tests/vault/gear/scheduler-commutator-test.cpp b/tests/vault/gear/scheduler-commutator-test.cpp
index cd61e2b15..d804336a6 100644
--- a/tests/vault/gear/scheduler-commutator-test.cpp
+++ b/tests/vault/gear/scheduler-commutator-test.cpp
@@ -51,6 +51,7 @@ namespace test {
// using lib::time::FrameRate;
// using lib::time::Offset;
using lib::time::Time;
+ using lib::time::FSecs;
using std::atomic_bool;
using lib::ThreadHookable;
using lib::thread::ThreadWrapper;
@@ -341,10 +342,9 @@ namespace test {
SchedulerInvocation queue;
SchedulerCommutator sched;
- Time t1{10,0};
- Time t2{20,0};
- Time t3{30,0};
- Time now{t2};
+ Time now = detector.executionCtx.getSchedTime();
+ Time past {Time::ZERO};
+ Time future{now+now};
// no one holds the GroomingToken
___ensureGroomingTokenReleased(sched);
@@ -356,12 +356,14 @@ namespace test {
CHECK (not sched.holdsGroomingToken (myself));
// Activity immediately dispatched when on time and GroomingToken can be acquired
- CHECK (activity::PASS == sched.postDispatch (&activity, t1, detector.executionCtx, queue));
+ CHECK (activity::PASS == sched.postDispatch (&activity, past, detector.executionCtx, queue));
+ CHECK (detector.verifyInvocation("testActivity").timeArg(now)); // was invoked immediately
CHECK ( sched.holdsGroomingToken (myself));
CHECK ( queue.empty());
+ detector.incrementSeq(); // mark this point in the log
// future Activity is enqueued by short-circuit directly into the PriorityQueue if possible
- CHECK (activity::PASS == sched.postDispatch (&activity, t3, detector.executionCtx, queue));
+ CHECK (activity::PASS == sched.postDispatch (&activity, future, detector.executionCtx, queue));
CHECK ( sched.holdsGroomingToken (myself));
CHECK (not queue.empty());
CHECK (isSameObject (activity, *queue.peekHead())); // appears at Head, implying it's in Priority-Queue
@@ -372,17 +374,18 @@ namespace test {
CHECK (queue.empty());
// ...but GroomingToken is not acquired explicitly; Activity is just placed into the Instruct-Queue
- CHECK (activity::PASS == sched.postDispatch (&activity, t3, detector.executionCtx, queue));
+ CHECK (activity::PASS == sched.postDispatch (&activity, future, detector.executionCtx, queue));
CHECK (not sched.holdsGroomingToken (myself));
CHECK (not queue.peekHead()); // not appearing at Head this time,
CHECK (not queue.empty()); // rather waiting in the Instruct-Queue
blockGroomingToken(sched);
- CHECK (activity::PASS == sched.postDispatch (&activity, t2, detector.executionCtx, queue));
+ CHECK (activity::PASS == sched.postDispatch (&activity, now, detector.executionCtx, queue));
CHECK (not sched.holdsGroomingToken (myself));
CHECK (not queue.peekHead()); // was enqueued, not executed
+ unblockGroomingToken();
cout << detector.showLog()<
-
-
+
+
@@ -85121,7 +85121,7 @@ Date: Thu Apr 20 18:53:17 2023 +0200