diff --git a/src/vault/gear/scheduler-commutator.hpp b/src/vault/gear/scheduler-commutator.hpp index bd574fcde..b4caf8969 100644 --- a/src/vault/gear/scheduler-commutator.hpp +++ b/src/vault/gear/scheduler-commutator.hpp @@ -74,7 +74,7 @@ namespace gear { void doWork (SchedulerInvocation& layer1) { - layer1.feedPriorisation(); + layer1.feedPrioritisation(); while (layer1.isDue (currentSchedulerTime())) { Activity* activity = layer1.pullHead(); diff --git a/src/vault/gear/scheduler-invocation.hpp b/src/vault/gear/scheduler-invocation.hpp index 620ed58ba..946822c1f 100644 --- a/src/vault/gear/scheduler-invocation.hpp +++ b/src/vault/gear/scheduler-invocation.hpp @@ -120,7 +120,7 @@ namespace gear { * and enqueue them according to time order */ void - feedPriorisation() + feedPrioritisation() { ActOrder actOrder; while (instruct_.pop (actOrder)) @@ -133,7 +133,7 @@ namespace gear { * effectively bypassing the thread dispatching entrance queue. */ void - feedPriorisation (Activity& activity, Time when) + feedPrioritisation (Activity& activity, Time when) { priority_.push (ActOrder{waterLevel(when), &activity}); } diff --git a/tests/32scheduler.tests b/tests/32scheduler.tests index 49ab44cab..4cc580520 100644 --- a/tests/32scheduler.tests +++ b/tests/32scheduler.tests @@ -20,7 +20,7 @@ END -PLANNED "Scheduler Layer-1" SchedulerInvocation_test < - using test::Test; -//using std::move; using util::isSameObject; @@ -42,11 +37,6 @@ namespace vault{ namespace gear { namespace test { -// using lib::time::FrameRate; -// using lib::time::Offset; -// using lib::time::Time; - - @@ -64,6 +54,8 @@ namespace test { simpleUsage(); verify_Queuing(); verify_WaterLevel(); + verify_stability(); + verify_isDue(); } @@ -79,32 +71,119 @@ namespace test { CHECK (not sched.peekHead()); sched.instruct (activity, when); - sched.feedPriorisation(); + sched.feedPrioritisation(); CHECK (sched.peekHead()); Activity* head = sched.pullHead(); CHECK (not sched.peekHead()); - CHECK (isSameObject (*head, activity)); + CHECK (isSameObject (*head, activity)); } - /** @test TODO verify records are passed properly through the queues + /** @test verify records are passed properly through the queues + * - add multiple elements to the instruct queue + * - after `feedPrioritisation` these appear as output */ void verify_Queuing() { - UNIMPLEMENTED ("queues"); + SchedulerInvocation sched; + Activity one{1u,1u}; + Activity two{2u,2u}; + Activity ree{3u,3u}; + Time t{5,5}; + + sched.instruct (one, t); + sched.instruct (two, t); + sched.instruct (ree, t); + CHECK (not sched.peekHead()); + + sched.feedPrioritisation(); + CHECK (isSameObject (*sched.pullHead(), one)); + CHECK (isSameObject (*sched.pullHead(), two)); + CHECK (isSameObject (*sched.pullHead(), ree)); + CHECK (not sched.peekHead()); } - /** @test TODO verify the given time point is utilised for prioritisation + /** @test verify the given time point is utilised for prioritisation + * - order at output is determined by the time spec + * - even later added elements can push back + * previously visible elements at head */ void verify_WaterLevel() { - UNIMPLEMENTED ("water level"); + SchedulerInvocation sched; + Activity a1{1u,1u}; + Activity a2{2u,2u}; + Activity a3{3u,3u}; + Activity a4{4u,4u}; + + sched.instruct (a2, Time{2,0}); + sched.instruct (a4, Time{4,0}); + sched.feedPrioritisation(); + CHECK (isSameObject (*sched.peekHead(), a2)); + + sched.instruct (a3, Time{3,0}); + sched.instruct (a1, Time{1,0}); + CHECK (isSameObject (*sched.peekHead(), a2)); + + sched.feedPrioritisation(); + CHECK (isSameObject (*sched.pullHead(), a1)); + CHECK (isSameObject (*sched.pullHead(), a2)); + CHECK (isSameObject (*sched.pullHead(), a3)); + CHECK (isSameObject (*sched.pullHead(), a4)); + } + + + + /** @test sort order is not necessarily stable + * if using identical time specs on entrance + */ + void + verify_stability() + { + SchedulerInvocation sched; + Activity a1{1u,1u}; + Activity a2{2u,2u}; + Activity a3{3u,3u}; + Activity a4{4u,4u}; + + sched.feedPrioritisation (a1, Time{0,5}); + sched.feedPrioritisation (a2, Time{0,5}); + sched.feedPrioritisation (a3, Time{0,5}); + sched.feedPrioritisation (a4, Time{0,4}); + CHECK (isSameObject (*sched.pullHead(), a4)); + CHECK (isSameObject (*sched.pullHead(), a3)); + CHECK (isSameObject (*sched.pullHead(), a1)); + CHECK (isSameObject (*sched.pullHead(), a2)); + CHECK (not sched.pullHead()); + } + + + + /** @test the entry appearing at head _is due_ + * when its time is at or before current time. + */ + void + verify_isDue() + { + SchedulerInvocation sched; + Activity a1{1u,1u}; + + sched.feedPrioritisation (a1, Time{0,5}); + CHECK (isSameObject (*sched.peekHead(), a1)); + CHECK ( sched.isDue (Time{0,10})); + CHECK ( sched.isDue (Time{0,5})); + CHECK (not sched.isDue (Time{0,1})); + + sched.pullHead(); + CHECK (not sched.peekHead()); + CHECK (not sched.isDue (Time{0,1})); + CHECK (not sched.isDue (Time{0,10})); } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 1c3c3dc9d..90f47e0f0 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -81687,14 +81687,14 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - - - - + + + + + - - + + @@ -81703,7 +81703,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -81762,7 +81762,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -81807,8 +81807,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + @@ -85868,12 +85869,12 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + - + @@ -85881,16 +85882,26 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - - + + - - + + + + + + + + + + + +