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 R,
class Cond = noReferenceCond<F>>
89 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
92 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
95 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
97 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
100 template<
class T>
T*
Reduce(
const std::vector<T*> &mergeObjs);
105 return *
static_cast<subc*
>(
this);
114 template<
class subc>
template<
class F,
class Cond>
124 template<
class subc>
template<
class F,
class INTEGER,
class Cond>
134 template<
class subc>
template<
class F,
class T,
class Cond>
137 std::vector<T> vargs(std::move(args));
138 const auto &reslist =
Map(
func, vargs);
148 template<
class subc>
template<
class F,
class T,
class Cond>
160 template<
class subc>
template<
class F,
class R,
class Cond>
166 template<
class subc>
template<
class F,
class INTEGER,
class R,
class Cond>
172 template<
class subc>
template<
class F,
class T,
class R,
class Cond>
178 template<
class subc>
template<
class F,
class T,
class R,
class Cond>
184 template<
class subc>
template<
class F,
class T,
class Cond>
193 template<
class subc>
template<
class T>
197 for(
unsigned i =1; i<mergeObjs.size(); i++){
201 auto retHist =
dynamic_cast<T*
>((mergeObjs.front())->Clone());
202 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.
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.
auto MapReduce(F func, unsigned nTimes, R redfunc) -> typename std::result_of< F()>::type
This method behaves just like Map, but an additional redfunc function must be provided.
double func(double *x, double *p)
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