11 #ifndef ROOT_TSequentialExecutor 12 #define ROOT_TSequentialExecutor 14 #include "RConfigure.h" 30 void Foreach(
F func,
unsigned nTimes);
31 template<
class F,
class INTEGER>
34 template<
class F,
class T>
35 void Foreach(
F func, std::initializer_list<T> args);
37 template<
class F,
class T>
38 void Foreach(
F func, std::vector<T> &args);
41 template<
class F,
class Cond = noReferenceCond<F>>
43 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
45 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
53 template<
class F,
class R,
class Cond = noReferenceCond<F>>
55 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
59 template<
class T,
class R>
auto Reduce(
const std::vector<T> &objs,
R redfunc) -> decltype(redfunc(objs));
70 for (
auto i = 0U; i < nTimes; ++i) func();
76 template<
class F,
class INTEGER>
78 for(
auto i : args) func(i);
85 template<
class F,
class T>
87 std::vector<T> vargs(std::move(args));
95 template<
class F,
class T>
97 unsigned int nToProcess = args.size();
106 template<
class F,
class Cond>
108 using retType = decltype(func());
109 std::vector<retType> reslist(nTimes);
110 for(
auto i:
ROOT::TSeqI(nTimes)) reslist[i] = func();
118 template<
class F,
class INTEGER,
class Cond>
120 using retType = decltype(func(*args.begin()));
121 std::vector<retType> reslist(*args.end()-*args.begin());
122 for(
auto i: args) reslist[i] = func(i);
132 template<
class F,
class T,
class Cond>
135 using retType = decltype(func(args.front()));
136 unsigned int nToProcess = args.size();
137 std::vector<retType> reslist(nToProcess);
138 for(
auto i:
ROOT::TSeqI(nToProcess)) reslist[i] = func(args[i]);
142 template<
class F,
class R,
class Cond>
144 return Reduce(
Map(func, nTimes), redfunc);
147 template<
class F,
class T,
class R,
class Cond>
155 template<
class T,
class R>
159 static_assert(std::is_same<decltype(redfunc(objs)),
T>::value,
"redfunc does not have the correct signature");
160 return redfunc(objs);
Namespace for new ROOT classes and functions.
TSequentialExecutor & operator=(TSequentialExecutor &)=delete
auto MapReduce(F func, unsigned nTimes, R redfunc) -> typename std::result_of< F()>::type
auto Map(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Execute func (with no arguments) nTimes.
This class defines an interface to execute the same task multiple times in parallel, possibly with different arguments every time.
#define R(a, b, c, d, e, f, g, h, i)
void Foreach(F func, unsigned nTimes)
Execute func (with no arguments) nTimes.
auto Reduce(const std::vector< T > &objs, R redfunc) -> decltype(redfunc(objs))
"Reduce" an std::vector into a single object by passing a function as the second argument defining th...
A pseudo container class which is a generator of indices.