parallel_for.h
| File Path | engine/include/conjure/core/jobs/parallel_for.h |
| API ↗ | Jobs and threading |
Convenience wrappers around job_system::parallel_for that accept any callable instead of a std::function. The wrapper std::function is built once per call and holds only references, so it stays within the small-object buffer and the dispatch remains allocation-free.
Functions
Public
jobs::default_grain
jobs::default_grainGrain used by the per-index parallel_for: max(1, count / (workerCount * 4)), treating zero workers as one.
jobs::parallel_for_each
jobs::parallel_for_eachtemplate <typename ElementType, typename Body> void parallel_for_each(job_system &system, std::span<ElementType> items, usize grain, Body &&body);Runs body(item) for every element of the span, grain elements per job.
template <typename ElementType, typename Body> void parallel_for_each(job_system &system, std::span<ElementType> items, Body &&body);Runs body(item) for every element of the span with the default grain.
jobs::parallel_for_range
jobs::parallel_for_rangetemplate <typename Body> void parallel_for_range(job_system &system, usize count, usize grain, Body &&body);Runs body(begin, end) over [0, count) in ranges of at most grain elements.