Prefer to read without ads? Become a member — from $10/month — and support the work. Already a member? Log in to read ad-free on this device.
A.2 Threading
The multithreaded samples use the C++ standard library’s threading
facilities directly: std::thread for the worker threads,
std::mutex and std::condition_variable for
synchronization, and std::thread::hardware_concurrency() to
report the number of CPU cores. The usual pattern is a fan-out/join – a
std::vector<std::thread> is filled with one worker
per CPU core (or per GPU), each handed its slice of the problem, then
joined. chLib no longer wraps threading of its own: before C++11 added
portable threads to the standard library, chLib provided a small
worker-thread pool for this purpose, but the standard facilities now
serve directly.