14 #ifdef ACTS_EXAMPLES_NO_TBB
15 #define ACTS_EXAMPLES_WITH_TBB(a)
18 #define ACTS_EXAMPLES_WITH_TBB(a) a
21 #include <tbb/parallel_for.h>
22 #include <tbb/queuing_mutex.h>
23 #include <tbb/task_arena.h>
26 namespace ActsExamples {
44 #ifdef ACTS_EXAMPLES_NO_TBB
46 namespace task_arena {
47 constexpr
int automatic = -1;
50 template <
typename Value>
51 struct blocked_range {
52 blocked_range(
Value begin_,
Value end_) : my_end(end_), my_begin(begin_) {}
70 static bool setting =
false;
71 if (nthreads != -99) {
72 #ifdef ACTS_EXAMPLES_NO_TBB
74 throw std::runtime_error(
75 "tbb is not available, so can't do multi-threading.");
78 bool newSetting = (nthreads != 1);
79 if (!setting && newSetting) {
92 #ifndef ACTS_EXAMPLES_NO_TBB
93 std::optional<tbb::task_arena>
tbb;
100 #ifndef ACTS_EXAMPLES_NO_TBB
101 tbb.emplace(nthreads, res);
106 template <
typename F>
108 #ifndef ACTS_EXAMPLES_NO_TBB
122 template <
typename R,
typename F>
124 #ifndef ACTS_EXAMPLES_NO_TBB
126 tbb::parallel_for(r, f);
130 for (
auto i = r.begin();
i != r.end(); ++
i) {
139 #ifndef ACTS_EXAMPLES_NO_TBB
140 std::optional<tbb::queuing_mutex>
tbb;
145 #ifndef ACTS_EXAMPLES_NO_TBB
153 #ifndef ACTS_EXAMPLES_NO_TBB
154 std::optional<tbb::queuing_mutex::scoped_lock>
tbb;
159 #ifndef ACTS_EXAMPLES_NO_TBB
167 #ifndef ACTS_EXAMPLES_NO_TBB