28 static unsigned int NumThreads(
void) {
return tbb::this_task_arena::max_concurrency(); }
31 template <
typename... Functions>
32 static void ParallelSections(Functions&&... funcs)
34 tbb::parallel_invoke(std::forward<Functions>(funcs)...);
38 template <
typename Function>
39 static void ParallelFor(
size_t begin,
size_t end, Function&& func)
41 static const bool NeedsThreadIndex =
42 std::is_convertible_v<Function, std::function<void(
unsigned int,
size_t)>>;
47 for (
size_t i = begin; i < end; ++i) {
48 if constexpr (NeedsThreadIndex)
49 func(thread_index, i);
56 tbb::blocked_range<size_t>(begin, end),
57 [&](
const tbb::blocked_range<size_t>& r) {
58 int thread_index = tbb::this_task_arena::current_thread_index();
60 for (
size_t i = r.begin(); i < r.end(); ++i) {
61 if constexpr (NeedsThreadIndex)
62 func(thread_index, i);