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

Description

Test:
WorkForce-Service: maintain a pool of active worker threads.
Warning
this test relies on empirical timings and can be brittle.
See also
SchedulerUsage_test

Definition at line 103 of file work-force-test.cpp.

Private Member Functions

virtual void run (Arg)
 
void simpleUsage ()
 
void verify_countActive ()
 
void verify_defaultPool ()
 
void verify_detectError ()
 
void verify_dtor_blocks ()
 
void verify_finalHook ()
 
void verify_pullWork ()
 
void verify_scalePool ()
 
void verify_workerDismiss ()
 
void verify_workerHalt ()
 
void verify_workerRetard ()
 
void verify_workerSleep ()
 

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

◆ simpleUsage()

void simpleUsage ( )
inlineprivate
Test:
demonstrate simple worker pool usage

Definition at line 128 of file work-force-test.cpp.

References vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_pullWork()

void verify_pullWork ( )
inlineprivate
Test:
the given work-functor is invoked repeatedly, once activated.

Definition at line 146 of file work-force-test.cpp.

References vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_workerHalt()

void verify_workerHalt ( )
inlineprivate
Test:
can cause a worker to terminate by return-value from the work-functor

Definition at line 178 of file work-force-test.cpp.

References vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_workerSleep()

void verify_workerSleep ( )
inlineprivate
Test:
a worker can be sent to sleep, throttling the poll frequency.

Definition at line 203 of file work-force-test.cpp.

References vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_workerRetard()

void verify_workerRetard ( )
inlineprivate
Test:
a worker can be retarded and throttled in case of contention.

Definition at line 226 of file work-force-test.cpp.

References vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_workerDismiss()

void verify_workerDismiss ( )
inlineprivate
Test:
when a worker is sent into sleep-cycles for an extended time, the worker terminates itself.

Definition at line 252 of file work-force-test.cpp.

References vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_finalHook()

void verify_finalHook ( )
inlineprivate
Test:
verify invocation of a thread-termination callback

Definition at line 277 of file work-force-test.cpp.

References Config::COMPUTATION_CAPACITY, and vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_detectError()

void verify_detectError ( )
inlineprivate
Test:
exceptions emanating from within the worker are catched and reported by setting the isFailure argument flag of the finalHook functor invoked at worker termination.

Definition at line 304 of file work-force-test.cpp.

References vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_defaultPool()

void verify_defaultPool ( )
inlineprivate
Test:
by default, the WorkForce is initially inactive; once activated, it scales up to the number of cores reported by the runtime system.

Definition at line 342 of file work-force-test.cpp.

References Config::COMPUTATION_CAPACITY, and vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_scalePool()

void verify_scalePool ( )
inlineprivate
Test:
the number of (separate) workers can be scaled up, both stepwise and as fraction of full hardware concurrency

helper to count distinct thread-IDs

Definition at line 365 of file work-force-test.cpp.

References Config::COMPUTATION_CAPACITY, and vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_countActive()

void verify_countActive ( )
inlineprivate
Test:
dynamically determine count of currently active workers.

Definition at line 437 of file work-force-test.cpp.

References vault::gear::test::anonymous_namespace{work-force-test.cpp}::setup().

+ Here is the call graph for this function:

◆ verify_dtor_blocks()

void verify_dtor_blocks ( )
inlineprivate
Test:
verify that the WorkForce dtor waits for all active threads to disappear
  • use a work-functor which keeps all workers blocked
  • start the WorkForce within a separate thread
  • in this separate thread, cause the WorkForce destructor to be called
  • in the test main thread release the work-functor blocking
  • at this point, all workers return, detect shutdown and terminate

Definition at line 473 of file work-force-test.cpp.

+ Inheritance diagram for WorkForce_test:
+ Collaboration diagram for WorkForce_test:

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