12 #ifndef ROOT_TExecutor 13 #define ROOT_TExecutor 26 template<
class F,
class...
T>
27 using noReferenceCond =
typename std::enable_if<
"Function can't return a reference" && !(std::is_reference<
typename std::result_of<
F(
T...)>
::type>::value)>::
type;
32 template<
class F,
class Cond = noReferenceCond<F>>
34 template<
class F,
class T,
class Cond = noReferenceCond<F,
typename T::value_type>>
35 auto Map(
F func,
T &args) -> std::vector < decltype(++(args.begin()), args.end(),
func(args.front()))>;
37 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
39 template<
class F,
class Cond = noReferenceCond<F, TObject*>>
41 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
43 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
51 template<
class F,
class R,
class Cond = noReferenceCond<F>>
53 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
56 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
58 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
63 template<
class T,
class R>
auto Reduce(
const std::vector<T> &objs,
R redfunc) -> decltype(redfunc(objs));
64 template<
class T,
class BINARYOP>
auto Reduce(
const std::vector<T> &objs, BINARYOP redfunc) -> decltype(redfunc(objs.front(), objs.front()));
69 return *
static_cast<subc*
>(
this);
78 template<
class subc>
template<
class F,
class Cond>
94 template<
class subc>
template<
class F,
class INTEGER,
class Cond>
97 return Derived().Map(func, args);
100 template<
class subc>
template<
class F,
class T,
class Cond>
103 std::vector<T> vargs(std::move(args));
104 const auto &reslist =
Map(func, vargs);
111 template<
class subc>
template<
class F,
class T,
class Cond>
114 return Derived().Map(func, args);
123 template<
class subc>
template<
class F,
class R,
class Cond>
126 return Reduce(
Map(func, nTimes), redfunc);
137 template<
class subc>
template<
class F,
class INTEGER,
class R,
class Cond>
143 template<
class subc>
template<
class F,
class T,
class R,
class Cond>
149 template<
class subc>
template<
class F,
class T,
class R,
class Cond>
158 template<
class subc>
template<
class T,
class BINARYOP>
162 static_assert(std::is_same<decltype(redfunc(objs.front(), objs.front())),
T>::value,
"redfunc does not have the correct signature");
163 return Derived().Reduce(objs, redfunc);
166 template<
class subc>
template<
class T,
class R>
170 static_assert(std::is_same<decltype(redfunc(objs)),
T>::value,
"redfunc does not have the correct signature");
171 return redfunc(objs);
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
typename std::enable_if<"Function can't return a reference"&&!(std::is_reference< typename std::result_of< F(T...)>::type >::value)>::type noReferenceCond
auto Reduce(const std::vector< T > &objs, R redfunc) -> decltype(redfunc(objs))
Collection abstract base class.
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
double func(double *x, double *p)