12 #ifndef ROOT_TMPWorkerExecutor 13 #define ROOT_TMPWorkerExecutor 76 template<
class F,
class T =
void,
class R =
void>
90 unsigned code = msg.first;
92 std::string reply =
"S" + std::to_string(
GetNWorker());
95 msg.second->ReadUInt(n);
112 reply +=
": unknown code received: " + std::to_string(code);
126 template<class
F, class
R>
130 TMPWorker(), fFunc(func), fRedFunc(redfunc),
137 unsigned code = msg.first;
139 std::string reply =
"S" + std::to_string(
GetNWorker());
142 const auto &res =
fFunc();
155 reply +=
": unknown code received: " + std::to_string(code);
167 template<class F, class
T>
174 unsigned code = msg.first;
176 std::string reply =
"S" + std::to_string(
GetNWorker());
179 msg.second->ReadUInt(n);
182 reply +=
": unknown code received: " + std::to_string(code);
206 unsigned code = msg.first;
208 std::string myId =
"S" + std::to_string(
GetPid());
F fFunc
the function to be executed
void HandleInput(MPCodeBufPair &msg)
Handle a message with an EMPCode.
TMPWorkerExecutor(F func, R redfunc)
This class works together with TProcessExecutor to allow the execution of functions in server process...
TMPWorkerExecutor(F func, const std::vector< T > &args, R redfunc)
This class works in conjuction with TMPClient, reacting to messages received from it as specified by ...
int MPSend(TSocket *s, unsigned code)
Send a message with the specified code on the specified socket.
decltype(fFunc(fArgs.front())) fReducedResult
the result of the execution
unsigned GetNWorker() const
void HandleInput(MPCodeBufPair &msg)
Handle a message with an EMPCode.
Ask for a kFuncResult/kProcResult.
bool fCanReduce
true if fReducedResult can be reduced with a new result, false until we have produced one result ...
The message contains the result of a function execution.
std::pair< unsigned, std::unique_ptr< TBufferFile > > MPCodeBufPair
An std::pair that wraps the code and optional object contained in a message.
Execute function with the argument contained in the message.
std::vector< T > fArgs
a vector containing the arguments that must be passed to fFunc
R fRedFunc
the reduce function
static constexpr double s
void HandleInput(MPCodeBufPair &msg)
Handle a message with an EMPCode.
TMPWorkerExecutor(F func, const std::vector< T > &args)
F fFunc
the function to be executed
std::vector< T > fArgs
a vector containing the arguments that must be passed to fFunc
We are ready for the next task.
R fRedFunc
the reduce function
F fFunc
the function to be executed
Execute function without arguments.