12 #ifndef ROOT_TExecutor 13 #define ROOT_TExecutor 66 template<
class F,
class...
T>
67 using noReferenceCond =
typename std::enable_if<
"Function can't return a reference" && !(std::is_reference<
typename std::result_of<
F(
T...)>
::type>::value)>::
type;
72 template<
class F,
class Cond = noReferenceCond<F>>
74 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
77 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
80 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
87 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
90 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
93 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
96 template<
class T>
T*
Reduce(
const std::vector<T*> &mergeObjs);
101 return *
static_cast<subc*
>(
this);
110 template<
class subc>
template<
class F,
class Cond>
113 return Derived().Map(func, nTimes);
120 template<
class subc>
template<
class F,
class INTEGER,
class Cond>
123 return Derived().Map(func, args);
130 template<
class subc>
template<
class F,
class T,
class Cond>
133 std::vector<T> vargs(std::move(args));
134 const auto &reslist =
Map(func, vargs);
144 template<
class subc>
template<
class F,
class T,
class Cond>
147 return Derived().Map(func, args);
156 template<
class subc>
template<
class F,
class INTEGER,
class R,
class Cond>
159 std::vector<INTEGER> vargs(args.size());
160 std::copy(args.begin(), args.end(), vargs.begin());
161 return Derived().MapReduce(func, vargs, redfunc);
164 template<
class subc>
template<
class F,
class T,
class R,
class Cond>
167 std::vector<T> vargs(std::move(args));
168 return Derived().MapReduce(func, vargs, redfunc);
171 template<
class subc>
template<
class F,
class T,
class Cond>
180 template<
class subc>
template<
class T>
184 for(
unsigned i =1; i<mergeObjs.size(); i++){
188 auto retHist =
dynamic_cast<T*
>((mergeObjs.front())->Clone());
189 if (retHist) retHist->Merge(&l);
Namespace for new ROOT classes and functions.
This class defines an interface to execute the same task multiple times in parallel, possibly with different arguments every time.
auto MapReduce(F func, ROOT::TSeq< INTEGER > args, R redfunc) -> typename std::result_of< F(INTEGER)>::type
This method behaves just like Map, but an additional redfunc function must be provided.
typename std::enable_if<"Function can't return a reference" &&!(std::is_reference< typename std::result_of< F(T...)>::type >::value)>::type noReferenceCond
auto Map(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Execute func (with no arguments) nTimes in parallel.
A pseudo container class which is a generator of indices.
virtual void Add(TObject *obj)
T * Reduce(const std::vector< T *> &mergeObjs)
"Reduce" an std::vector into a single object by using the object's Merge