<blake3pp/parallel_backend.hpp>¶
Sizing the process-wide parallel scheduler.
P2079's get_parallel_scheduler() returns one scheduler per process and takes no size; beman.execution's default backend runs on hardware_concurrency() threads. A program chooses otherwise by replacing the backend behind it, one definition per program, which is what this header's definition does.
It is not part of <blake3pp/blake3pp.hpp>. The definition lives in the blake3pp::parallel_backend target, which BLAKE3PP_SIZED_PARALLEL_SCHEDULER builds: by default under the beman provider, where blake3pp::blake3pp links it, and on request under stdexec, where an executable links it. Without it the target does not exist and a call here fails to link. A beman program that defines its own backend configures with the option OFF.
#include <blake3pp/parallel_backend.hpp>
#include <blake3pp/parallel.hpp>
blake3pp::size_parallel_scheduler(8); // before anything uses it
auto d = blake3pp::hash(buf, blake3pp::get_parallel_scheduler());
The scheduler-taking overloads accept any scheduler: a caller who already owns an executor passes it and needs none of this.
Functions¶
size_parallel_scheduler¶
void size_parallel_scheduler(unsigned threads);
Fixes the number of threads the process-wide parallel scheduler runs on.
Call it once, before the first use of get_parallel_scheduler() (and before any hash overload that defaults to it), from one thread. The size applies to the program; several differently sized pools are schedulers the caller owns and passes explicitly.
| Parameter | |
|---|---|
threads |
Worker threads; must be at least 1. |
parallel_scheduler_threads¶
unsigned parallel_scheduler_threads() noexcept;
The size fixed by size_parallel_scheduler(), or 0 if none was.