36 using std::this_thread::sleep_for;
38 using std::chrono::milliseconds;
43 using WorkFun = std::function<work::SIG_WorkFun>;
44 using FinalFun = std::function<work::SIG_FinalHook>;
59 FinalFun finalHook = [](bool){ };
65 : doWork{std::forward<FUN> (workFun)}
69 withFinalHook (FinalFun finalFun)
71 finalHook = move (finalFun);
76 withSleepPeriod (std::chrono::milliseconds millis)
83 dismissAfter (
size_t cycles)
85 DISMISS_CYCLES = cycles;
91 return Setup{std::forward<FUN> (workFun)};
113 verify_workerSleep();
114 verify_workerRetard();
115 verify_workerDismiss();
117 verify_detectError();
118 verify_defaultPool();
120 verify_countActive();
121 verify_dtor_blocks();
130 atomic<uint> check{0};
148 atomic<uint> check{0};
156 uint invocations = check;
157 CHECK (0 < invocations);
160 CHECK (invocations < check);
164 CHECK (invocations < check);
170 CHECK (invocations == check);
180 atomic<uint> check{0};
181 atomic<activity::Proc> control{activity::PASS};
187 uint invocations = check;
188 CHECK (0 < invocations);
190 control = activity::HALT;
195 CHECK (invocations == check);
205 atomic<uint> check{0};
207 .withSleepPeriod (10ms)};
228 atomic<uint> check{0};
234 uint cyclesPASS{check};
241 uint cyclesKICK{check};
242 CHECK (cyclesKICK < cyclesPASS);
243 CHECK (cyclesKICK < 50);
254 atomic<uint> check{0};
256 .withSleepPeriod (10ms)
269 CHECK (0 == wof.size());
279 atomic<uint> exited{0};
280 atomic<activity::Proc> control{activity::PASS};
282 .withFinalHook([&](
bool){ ++exited; })};
291 control = activity::HALT;
293 CHECK (0 == wof.size());
306 atomic<uint> check{0};
307 atomic<uint> errors{0};
311 return activity::PASS;
313 .withFinalHook([&](
bool isFailure)
326 CHECK (3 == wof.size());
331 CHECK (2 == wof.size());
344 atomic<uint> check{0};
348 CHECK (0 == wof.size());
369 :
public std::set<std::thread::id>
374 mark (std::thread::id
const& tID)
380 operator size_t()
const 389 uniqueCnt.mark(std::this_thread::get_id());
390 return activity::PASS;
393 CHECK (0 == uniqueCnt);
394 CHECK (0 == wof.size());
398 CHECK (1 == uniqueCnt);
399 CHECK (1 == wof.size());
403 CHECK (2 == uniqueCnt);
404 CHECK (2 == wof.size());
411 CHECK (fullCnt == uniqueCnt);
412 CHECK (fullCnt == wof.size());
416 CHECK (2*fullCnt == uniqueCnt);
417 CHECK (2*fullCnt == wof.size());
420 CHECK (0 == wof.size());
424 CHECK (0 == uniqueCnt);
428 CHECK (fullCnt/2 == uniqueCnt);
429 CHECK (fullCnt/2 == wof.size());
439 atomic<uint> check{0};
442 if (check == 5
'000 or check == 5'110)
443 return activity::HALT;
445 return activity::PASS;
448 CHECK (0 == wof.size());
455 CHECK (3 == wof.size());
457 while (check < 6
'000) 458 sleep_for(15ms); // .....sufficiently long to count way beyond 10'000
459 CHECK (check > 6
'000); 460 CHECK (1 == wof.size()); 475 atomic<bool> trapped{true}; 476 auto blockingWork = [&]{ 479 return activity::PASS; 482 atomic<bool> pool_scaled_up{false}; 483 atomic<bool> shutdown_done{false}; 485 Thread operate{"controller" 488 WorkForce wof{setup (blockingWork)}; 492 CHECK (wof.size() == work::Config::COMPUTATION_CAPACITY); 493 pool_scaled_up = true; 494 } // WorkForce goes out of scope => dtor called 496 // when reaching this point, dtor has terminated 497 shutdown_done = true; 500 CHECK (operate); // operate-thread is in running state 503 CHECK (pool_scaled_up); 504 CHECK (not shutdown_done); // all workers are trapped in the work-functor 505 // thus the destructor can't dismantle the pool
508 CHECK (shutdown_done);
Facility for monitor object based locking.
const size_t DISMISS_CYCLES
number of wait cycles before an idle worker terminates completely
Object Monitor based synchronisation.
Derived specific exceptions within Lumiera's exception hierarchy.
Abstract Base Class for all testcases.
const auto IDLE_WAIT
sleep-recheck cycle for workers deemed idle
void verify_countActive()
Simplistic test class runner.
Convenience front-end to simplify and codify basic thread handling.
const milliseconds IDLE_WAIT
wait period when a worker falls idle
const size_t DISMISS_CYCLES
number of idle cycles after which the worker terminates
void verify_workerSleep()
auto setup(FUN &&workFun)
Helper: setup a Worker-Pool configuration for the test.
void verify_workerRetard()
A thin convenience wrapper to simplify thread-handling.
A pool of workers for multithreaded rendering.
static size_t COMPUTATION_CAPACITY
Nominal »full size« of a pool of concurrent workers.
void verify_defaultPool()
Proc
Result instruction from Activity activation.
Pool of worker threads for rendering.
Base for configuration of the worker pool.
Vault-Layer implementation namespace root.
void verify_workerDismiss()
void verify_detectError()