36 using std::this_thread::sleep_for;
37 using namespace std::chrono_literals;
38 using std::chrono::milliseconds;
43 using WorkFun = std::function<work::SIG_WorkFun>;
44 using FinalFun = std::function<work::SIG_FinalHook>;
61 milliseconds IDLE_WAIT = work::Config::IDLE_WAIT;
62 size_t DISMISS_CYCLES = work::Config::DISMISS_CYCLES;
65 : doWork{std::forward<FUN> (workFun)}
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)};
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};
187 uint invocations = check;
188 CHECK (0 < invocations);
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};
282 .withFinalHook([&](
bool){ ++exited; })};
293 CHECK (0 == wof.size());
306 atomic<uint> check{0};
307 atomic<uint> errors{0};
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());
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)
448 CHECK (0 == wof.size());
455 CHECK (3 == wof.size());
457 while (check < 6'000)
459 CHECK (check > 6'000);
460 CHECK (1 == wof.size());
475 atomic<bool> trapped{
true};
476 auto blockingWork = [&]{
482 atomic<bool> pool_scaled_up{
false};
483 atomic<bool> shutdown_done{
false};
485 Thread operate{
"controller"
493 pool_scaled_up =
true;
497 shutdown_done =
true;
503 CHECK (pool_scaled_up);
504 CHECK (not shutdown_done);
508 CHECK (shutdown_done);
Facility for monitor object based locking.
A thin convenience wrapper to simplify thread-handling.
Abstract Base Class for all testcases.
Pool of worker threads for rendering.
void verify_defaultPool()
void verify_workerSleep()
void verify_workerRetard()
void verify_workerDismiss()
void verify_dtor_blocks()
void verify_countActive()
void verify_detectError()
LumieraError< LERR_(STATE)> State
Test runner and basic definitions for tests.
Proc
Result instruction from Activity activation.
@ PASS
pass on the activation down the chain
@ KICK
back pressure; get out of the way but be back soon
@ WAIT
nothing to do; wait and re-check for work later
@ HALT
abandon this play / render process
auto setup(FUN &&workFun)
Helper: setup a Worker-Pool configuration for the test.
std::function< work::SIG_WorkFun > WorkFun
std::function< work::SIG_FinalHook > FinalFun
Vault-Layer implementation namespace root.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Base for configuration of the worker pool.
static size_t COMPUTATION_CAPACITY
Nominal »full size« of a pool of concurrent workers.
Object Monitor based synchronisation.
Convenience front-end to simplify and codify basic thread handling.
A pool of workers for multithreaded rendering.