diff --git a/src/vault/gear/load-controller.hpp b/src/vault/gear/load-controller.hpp index 0aceb9a6f..709823dfe 100644 --- a/src/vault/gear/load-controller.hpp +++ b/src/vault/gear/load-controller.hpp @@ -205,7 +205,8 @@ namespace gear { auto horizon = classifyTimeHorizon (Offset{head - now}); return horizon > SPINTIME and not tendedNext(head)? TENDNEXT - : horizon; + : horizon==IDLEWAIT ? WORKTIME + : horizon; } /** decide how this thread's capacity shall be used diff --git a/src/vault/gear/scheduler.hpp b/src/vault/gear/scheduler.hpp index dc0fb0aa5..10acbf42e 100644 --- a/src/vault/gear/scheduler.hpp +++ b/src/vault/gear/scheduler.hpp @@ -50,6 +50,7 @@ #include "vault/gear/scheduler-invocation.hpp" #include "vault/gear/load-controller.hpp" #include "vault/gear/engine-observer.hpp" +#include "vault/real-clock.hpp" //#include "lib/symbol.hpp" #include "lib/nocopy.hpp" //#include "lib/util.hpp" @@ -69,6 +70,10 @@ namespace gear { using lib::time::Offset; using lib::time::Duration; + namespace test { // declared friend for test access + class SchedulerService_test; + } + namespace { // Scheduler default config const auto IDLE_WAIT = 20ms; ///< sleep-recheck cycle for workers deemed _idle_ @@ -226,6 +231,10 @@ namespace gear { /** @internal expose a binding for Activity execution */ class ExecutionCtx; + + + /** open private backdoor for tests */ + friend class test::SchedulerService_test; }; @@ -284,10 +293,11 @@ namespace gear { return POLL_WAIT_DELAY; } + /** access high-resolution-clock, rounded to ยต-Ticks */ Time getSchedTime() { - UNIMPLEMENTED ("access scheduler Time"); + return RealClock::now(); } }; diff --git a/tests/vault/gear/scheduler-load-control-test.cpp b/tests/vault/gear/scheduler-load-control-test.cpp index cb1e8ac59..4b9c7e47e 100644 --- a/tests/vault/gear/scheduler-load-control-test.cpp +++ b/tests/vault/gear/scheduler-load-control-test.cpp @@ -191,9 +191,9 @@ namespace test { // but after marking `next` as tended, capacity can be directed elsewhere lctrl.tendNext (next); - CHECK (Capacity::IDLEWAIT == lctrl.markOutgoingCapacity (next, ut )); + CHECK (Capacity::WORKTIME == lctrl.markOutgoingCapacity (next, ut )); - CHECK (Capacity::IDLEWAIT == lctrl.markOutgoingCapacity (next, t1 )); + CHECK (Capacity::WORKTIME == lctrl.markOutgoingCapacity (next, t1 )); CHECK (Capacity::WORKTIME == lctrl.markOutgoingCapacity (next, t2 )); CHECK (Capacity::NEARTIME == lctrl.markOutgoingCapacity (next, t3 )); CHECK (Capacity::SPINTIME == lctrl.markOutgoingCapacity (next, t4 )); diff --git a/tests/vault/gear/scheduler-service-test.cpp b/tests/vault/gear/scheduler-service-test.cpp index 8db9e7100..d46674b28 100644 --- a/tests/vault/gear/scheduler-service-test.cpp +++ b/tests/vault/gear/scheduler-service-test.cpp @@ -26,9 +26,10 @@ #include "lib/test/run.hpp" +#include "activity-detector.hpp" #include "vault/gear/scheduler.hpp" -//#include "lib/time/timevalue.hpp" -//#include "lib/format-cout.hpp" +#include "lib/time/timevalue.hpp" +#include "lib/format-cout.hpp" //#include "lib/util.hpp" //#include @@ -44,7 +45,7 @@ namespace test { // using lib::time::FrameRate; // using lib::time::Offset; -// using lib::time::Time; + using lib::time::Time; @@ -64,8 +65,8 @@ namespace test { run (Arg) { simpleUsage(); + invokeWorkFunction(); walkingDeadline(); - setupLalup(); } @@ -82,13 +83,29 @@ namespace test { - /** @test TODO + /** @test TODO verify visible behaviour of the work-pulling function * @todo WIP 10/23 ๐Ÿ” define โŸถ implement */ void - walkingDeadline() + invokeWorkFunction() { - UNIMPLEMENTED ("walking Deadline"); + BlockFlowAlloc bFlow; + EngineObserver watch; + Scheduler scheduler{bFlow, watch}; + + ActivityDetector detector; + Activity& probe = detector.buildActivationProbe ("testProbe"); + + // this test class is declared friend to get a backdoor to Scheduler internals... + auto& schedCtx = Scheduler::ExecutionCtx::from(scheduler); + Time now = schedCtx.getSchedTime(); + schedCtx.post (now, &probe, schedCtx); + + CHECK (activity::WAIT == scheduler.getWork()); + + cout << detector.showLog()< - + + @@ -83115,6 +83116,23 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + +

+ wichtig falls der Scheduler leer fällt +

+ +
+ +
+ + +
@@ -88084,12 +88102,18 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + + + + + + @@ -88104,13 +88128,58 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -88118,6 +88187,12 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + +