11#ifndef ROOT_TSequentialExecutor
12#define ROOT_TSequentialExecutor
19#include <initializer_list>
29 template <
typename F,
typename... Args>
41 void Foreach(
F func,
unsigned nTimes);
42 template<
class F,
class INTEGER>
44 template<
class F,
class T>
45 void Foreach(
F func, std::initializer_list<T> args);
46 template<
class F,
class T>
47 void Foreach(
F func, std::vector<T> &args);
48 template<
class F,
class T>
49 void Foreach(
F func,
const std::vector<T> &args);
74 template<
class F,
class Cond = noReferenceCond<F>>
75 auto MapImpl(
F func,
unsigned nTimes) -> std::vector<InvokeResult_t<F>>;
76 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
78 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
79 auto MapImpl(
F func, std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>>;
80 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
81 auto MapImpl(
F func,
const std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>>;
93 for (
auto i = 0U; i < nTimes; ++i) func();
101 template<
class F,
class INTEGER>
103 for(
auto i : args) func(i);
111 template<
class F,
class T>
113 std::vector<T> vargs(std::move(args));
122 template<
class F,
class T>
124 for(
auto &&arg: args) {
134 template<
class F,
class T>
136 for(
auto &&arg: args) {
146 template<
class F,
class Cond>
148 using retType =
decltype(func());
149 std::vector<retType> reslist;
150 reslist.reserve(nTimes);
151 while(reslist.size() < nTimes) {
152 reslist.emplace_back(func());
162 template<
class F,
class INTEGER,
class Cond>
164 using retType =
decltype(func(*args.begin()));
165 std::vector<retType> reslist;
166 reslist.reserve(args.size());
168 reslist.emplace_back(func(i));
177 template<
class F,
class T,
class Cond>
180 using retType =
decltype(func(args.front()));
181 std::vector<retType> reslist;
182 reslist.reserve(args.size());
183 for(
auto &&arg: args) {
184 reslist.emplace_back(func(arg));
194 template<
class F,
class T,
class Cond>
197 using retType =
decltype(func(args.front()));
198 std::vector<retType> reslist;
199 reslist.reserve(args.size());
200 for(
auto &&arg: args) {
201 reslist.emplace_back(func(arg));
This class defines an interface to execute the same task multiple times, possibly in parallel and wit...
auto MapReduce(F func, unsigned nTimes, R redfunc) -> InvokeResult_t< F >
Execute a function without arguments several times (Map) and accumulate the results into a single val...
auto Map(F func, unsigned nTimes) -> std::vector< InvokeResult_t< F > >
Execute a function without arguments several times.
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
ROOT::TypeTraits::InvokeResult_t< F, Args... > InvokeResult_t
auto MapImpl(F func, unsigned nTimes) -> std::vector< InvokeResult_t< F > >
Execute a function without arguments several times.
TSequentialExecutor(const TSequentialExecutor &)=delete
TSequentialExecutor & operator=(const TSequentialExecutor &)=delete
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.