Lumiera  0.pre.03
»edit your freedom«
SchedulerCommutator_test Class Reference

Description

Test:
Scheduler Layer-2: coordination of Activity execution.
Remarks
Layer-2 combines the queue data structure from Layer-1 with the »Activity Language« to allow performing of Render Activities. This test verifies the proper integration of these building blocks
  • the Grooming-Token is an atomic lock tied to current thread-id; it will be acquired for all operations manipulating internal state
  • the ActivityDetector is used as a test helper to record calls and to verify the Activities are indeed activated as expected
  • the integratedWorkCycle() walks through all the steps typically happening when a Render-Job is first planned and scheduled, and then retrieved and executed by the WorkForce. However, these steps are invoked directly here, and with suitable instrumentation to watch processing in detail
  • the complete Scheduler functionality is assembled one level higher in the Scheduler-Service...
See also
SchedulerActivity_test
ActivityDetector_test
SchedulerUsage_test

Definition at line 81 of file scheduler-commutator-test.cpp.

Private Types

using Launch = ThreadHookable::Launch
 

Private Member Functions

void blockGroomingToken (SchedulerCommutator &sched)
 
void demonstrateSimpleUsage ()
 
void integratedWorkCycle ()
 
virtual void run (Arg)
 
void torture_GroomingToken ()
 
void unblockGroomingToken ()
 
void verify_dispatch ()
 
void verify_findWork ()
 
void verify_GroomingGuard ()
 
void verify_GroomingToken ()
 
void verify_postChain ()
 
void verify_Significance ()
 

Static Private Member Functions

static void ___ensureGroomingTokenReleased (SchedulerCommutator &sched)
 

Private Attributes

unique_ptr< ThreadHookablegroomingHog_
 
atomic_bool stopTheHog_ {false}
 

Additional Inherited Members

- Public Member Functions inherited from Test
virtual ~Test ()=default
 this is an interface
 
lib::Random makeRandGen ()
 build a dedicated new RandomGen, seeded from the default-Gen
 
virtual void run (Arg arg)=0
 
void seedRand ()
 draw a new random seed from a common nucleus, and re-seed the default-Gen.
 
- Static Public Member Functions inherited from Test
static string firstTok (Arg)
 conveniently pick the first token from the argument line
 
static uint firstVal (Arg, uint=1)
 conveniently use some number given as argument, with optional default
 

Member Function Documentation

◆ demonstrateSimpleUsage()

void demonstrateSimpleUsage ( )
inlineprivate
Test:
demonstrate a simple usage scenario

Definition at line 103 of file scheduler-commutator-test.cpp.

References ActivityMatch::arg(), ActivityLang::dispatchChain(), SchedulerCommutator::findWork(), and MARK_TEST_FUN.

+ Here is the call graph for this function:

◆ verify_GroomingToken()

void verify_GroomingToken ( )
inlineprivate
Test:
verify logic to control concurrent execution

Definition at line 134 of file scheduler-commutator-test.cpp.

References SchedulerCommutator_test::___ensureGroomingTokenReleased(), and MARK_TEST_FUN.

+ Here is the call graph for this function:

◆ ___ensureGroomingTokenReleased()

static void ___ensureGroomingTokenReleased ( SchedulerCommutator sched)
inlinestaticprivate

helper to ensure consistent Grooming-Token state

Definition at line 152 of file scheduler-commutator-test.cpp.

References SchedulerCommutator::acquireGoomingToken(), SchedulerCommutator::dropGroomingToken(), and SchedulerCommutator::holdsGroomingToken().

Referenced by SchedulerCommutator_test::integratedWorkCycle(), SchedulerCommutator_test::verify_GroomingGuard(), SchedulerCommutator_test::verify_GroomingToken(), and SchedulerCommutator_test::verify_postChain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verify_GroomingGuard()

void verify_GroomingGuard ( )
inlineprivate
Test:
verify extended logic to protect a scope
  • if the thread already holds the grooming token, nothing happens
  • otherwise, it is acquired (blocking) and dropped on exit

Definition at line 167 of file scheduler-commutator-test.cpp.

References SchedulerCommutator_test::___ensureGroomingTokenReleased(), MARK_TEST_FUN, SchedulerCommutator::requireGroomingTokenHere(), and vault::gear::anonymous_namespace{scheduler-commutator.hpp}::thisThread().

+ Here is the call graph for this function:

◆ torture_GroomingToken()

void torture_GroomingToken ( )
inlineprivate
Test:
ensure the GroomingToken mechanism indeed creates mutual exclusion to protected against concurrent corruption.
Remarks
uses lib::test::threadBenchmark() to put the test-subject under pressure by strongly contended parallel execution.

Definition at line 201 of file scheduler-commutator-test.cpp.

References MARK_TEST_FUN.

◆ blockGroomingToken()

void blockGroomingToken ( SchedulerCommutator sched)
inlineprivate

Helper to block the GroomingToken from another thread

Definition at line 243 of file scheduler-commutator-test.cpp.

References SchedulerCommutator::acquireGoomingToken(), ThreadWrapper::detach_thread_from_wrapper(), SchedulerCommutator::dropGroomingToken(), and SchedulerCommutator::holdsGroomingToken().

Referenced by SchedulerCommutator_test::verify_dispatch(), SchedulerCommutator_test::verify_findWork(), and SchedulerCommutator_test::verify_postChain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unblockGroomingToken()

void unblockGroomingToken ( )
inlineprivate

stop the background thread to unblock the GrooingToken

Definition at line 269 of file scheduler-commutator-test.cpp.

Referenced by SchedulerCommutator_test::verify_dispatch(), SchedulerCommutator_test::verify_findWork(), and SchedulerCommutator_test::verify_postChain().

+ Here is the caller graph for this function:

◆ verify_findWork()

void verify_findWork ( )
inlineprivate
Test:
verify logic of queue updates and work prioritisation.

Definition at line 281 of file scheduler-commutator-test.cpp.

References SchedulerCommutator_test::blockGroomingToken(), SchedulerCommutator::findWork(), MARK_TEST_FUN, and SchedulerCommutator_test::unblockGroomingToken().

+ Here is the call graph for this function:

◆ verify_Significance()

void verify_Significance ( )
inlineprivate
Test:
verify that obsoleted or rejected entries are dropped transparently
  • add entries providing extra information regarding significance
  • verify that missing the deadline is detected
  • entries past deadline will be dropped when pulling for work
  • entries tagged with an ManifestationID can be disabled and will be automatically disposed.
  • an entry marked as compulsory will block that process when missing it's deadline

Definition at line 346 of file scheduler-commutator-test.cpp.

References Activity::activate(), SchedulerCommutator::findWork(), and MARK_TEST_FUN.

+ Here is the call graph for this function:

◆ verify_postChain()

◆ verify_dispatch()

void verify_dispatch ( )
inlineprivate
Test:
verify basic functionality to dequeue and dispatch entries.
Remarks
this is actually the core of the »work-function«, and can not easily be demonstrated on a unit-test level, due to the interplay with timing and load distribution. So this test is limited to show that an entry passes through the queues and is dispatched
See also
SchedulerService_test::invokeWorkFunction() for a more comprehensive integration test

Definition at line 501 of file scheduler-commutator-test.cpp.

References SchedulerCommutator_test::blockGroomingToken(), SchedulerCommutator::dispatchCapacity(), ActivityLang::dispatchChain(), SchedulerInvocation::feedPrioritisation(), SchedulerInvocation::headTime(), SchedulerCommutator::holdsGroomingToken(), SchedulerInvocation::instruct(), MARK_TEST_FUN, Time::NEVER, and SchedulerCommutator_test::unblockGroomingToken().

+ Here is the call graph for this function:

◆ integratedWorkCycle()

void integratedWorkCycle ( )
inlineprivate
Test:
step-wise perform the typical sequence of planning and worker activation
  • use the Render-Job scenario from SchedulerActivity_test::scenario_RenderJob()
  • use similar instrumentation to trace Activities
  • specifically rig the diagnostic executionCtx to drop the GroomingToken at λ-work
  • Step-1 : schedule the Activity-term
  • Step-2 : later search for work, retrieve and dispatch the term
  • verify the expected sequence of Activities actually occurred
See also
ActivityLang::buildCalculationJob()
ActivityDetector::buildMockJob()

Definition at line 570 of file scheduler-commutator-test.cpp.

References SchedulerCommutator_test::___ensureGroomingTokenReleased(), ActivityMatch::arg(), ActivityLang::dispatchChain(), SchedulerCommutator::dropGroomingToken(), SchedulerCommutator::findWork(), SchedulerCommutator::holdsGroomingToken(), ActivityDetector::incrementSeq(), MARK_TEST_FUN, Activity::next, and SchedulerCommutator::postChain().

+ Here is the call graph for this function:
+ Inheritance diagram for SchedulerCommutator_test:
+ Collaboration diagram for SchedulerCommutator_test:

The documentation for this class was generated from the following file: