39 using std::atomic_uint;
40 using std::this_thread::yield;
41 using std::this_thread::sleep_for;
42 using std::chrono::microseconds;
50 const uint NUM_THREADS = 200;
51 const uint REPETITIONS = 10;
78 Thread thread(
"counter", [&]{ ++i; });
79 while (thread) yield();
103 using Thread::Thread;
108 doIt (uint a, uint b)
111 sleep_for (microseconds{sum});
120 size_t globalSum = 0;
121 auto launchThreads = [&]
123 for (uint i=1; i<=NUM_THREADS; ++i)
125 uint x = rand() % 1000;
126 globalSum += (i + x);
127 threads.emplace (&TestThread::doIt, i, x);
130 while (
explore(threads).has_any())
133 for (
auto& t : threads)
142 CHECK (checkSum == globalSum);
143 CHECK (runTime < NUM_THREADS * 1000/2);
A fixed collection of non-copyable polymorphic objects.
auto explore(IT &&srcSeq)
start building a IterExplorer by suitably wrapping the given iterable source.
void verifyConcurrentExecution()
Functions to perform (multithreaded) timing measurement on a given functor.
Implementation namespace for support and library code.
Managing a collection of non-copyable polymorphic objects in compact storage.
double benchmarkTime(FUN const &invokeTestCode, const size_t repeatCnt=1)
Helper to invoke a functor or λ to observe its running time.
Abstract Base Class for all testcases.
Simple test class runner.
Convenience front-end to simplify and codify basic thread handling.
void demonstrateSimpleUsage()
A thin convenience wrapper to simplify thread-handling.
Building tree expanding and backtracking evaluations within hierarchical scopes.