11#ifndef ROOT_TSequentialExecutor
12#define ROOT_TSequentialExecutor
18#include <initializer_list>
37 void Foreach(
F func,
unsigned nTimes);
38 template<
class F,
class INTEGER>
40 template<
class F,
class T>
41 void Foreach(
F func, std::initializer_list<T> args);
42 template<
class F,
class T>
43 void Foreach(
F func, std::vector<T> &args);
44 template<
class F,
class T>
45 void Foreach(
F func,
const std::vector<T> &args);
70 template<
class F,
class Cond = noReferenceCond<F>>
71 auto MapImpl(
F func,
unsigned nTimes) -> std::vector<
typename std::result_of<
F()>
::type>;
72 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
74 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
75 auto MapImpl(
F func, std::vector<T> &args) -> std::vector<
typename std::result_of<
F(T)>
::type>;
76 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
77 auto MapImpl(
F func,
const std::vector<T> &args) -> std::vector<
typename std::result_of<
F(T)>
::type>;
89 for (
auto i = 0U; i < nTimes; ++i) func();
97 template<
class F,
class INTEGER>
99 for(
auto i : args) func(i);
107 template<
class F,
class T>
109 std::vector<T> vargs(std::move(args));
118 template<
class F,
class T>
120 for(
auto &&arg: args) {
130 template<
class F,
class T>
132 for(
auto &&arg: args) {
142 template<
class F,
class Cond>
144 using retType =
decltype(func());
145 std::vector<retType> reslist;
146 reslist.reserve(nTimes);
147 while(reslist.size() < nTimes) {
148 reslist.emplace_back(func());
158 template<
class F,
class INTEGER,
class Cond>
160 using retType =
decltype(func(*args.begin()));
161 std::vector<retType> reslist;
162 reslist.reserve(args.size());
164 reslist.emplace_back(func(i));
173 template<
class F,
class T,
class Cond>
176 using retType =
decltype(func(args.front()));
177 std::vector<retType> reslist;
178 reslist.reserve(args.size());
179 for(
auto &&arg: args) {
180 reslist.emplace_back(func(arg));
190 template<
class F,
class T,
class Cond>
193 using retType =
decltype(func(args.front()));
194 std::vector<retType> reslist;
195 reslist.reserve(args.size());
196 for(
auto &&arg: args) {
197 reslist.emplace_back(func(arg));
This class defines an interface to execute the same task multiple times, possibly in parallel and wit...
auto Map(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Execute a function without arguments several times.
auto MapReduce(F func, unsigned nTimes, R redfunc) -> typename std::result_of< F()>::type
Execute a function without arguments several times (Map) and accumulate the results into a single val...
T * Reduce(const std::vector< T * > &mergeObjs)
"Reduce" an std::vector into a single object by using the object's Merge method.
A pseudo container class which is a generator of indices.
void Foreach(F func, unsigned nTimes)
Execute a function without arguments several times, dividing the execution in nChunks.
unsigned GetPoolSize() const
Return the number of workers in the sequential executor: a single one.
TSequentialExecutor()=default
auto MapImpl(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Execute a function without arguments several times.
TSequentialExecutor(const TSequentialExecutor &)=delete
TSequentialExecutor & operator=(const TSequentialExecutor &)=delete
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...