Logo ROOT   6.16/01
Reference Guide
List of all members | Public Member Functions | Private Attributes | List of all members
TMPWorkerExecutor< F, T, R > Class Template Reference

template<class F, class T = void, class R = void>
class TMPWorkerExecutor< F, T, R >

This class works together with TProcessExecutor to allow the execution of functions in server processes.

Depending on the exact task that the worker is required to execute, a different version of the class can be called.

TMPWorkerExecutor<F, T, R>

The most general case, used by TProcessExecutor::MapReduce(F func, T& args, R redfunc). This worker is build with:

Partial specializations

A few partial specializations are provided for less general cases:

Since all the important data are passed to TMPWorkerExecutor at construction time, the kind of messages that client and workers have to exchange are usually very simple.

Definition at line 77 of file TMPWorkerExecutor.h.

Public Member Functions

 TMPWorkerExecutor (F func, const std::vector< T > &args, R redfunc)
 
 ~TMPWorkerExecutor ()
 
void HandleInput (MPCodeBufPair &msg)
 Handle a message with an EMPCode. More...
 
- Public Member Functions inherited from TMPWorker
 TMPWorker ()
 
 TMPWorker (const TMPWorker &)=delete
 
 TMPWorker (unsigned nWorkers, ULong64_t maxEntries)
 
virtual ~TMPWorker ()
 
unsigned GetNWorker () const
 
pid_t GetPid ()
 
TSocketGetSocket ()
 
virtual void Init (int fd, unsigned workerN)
 This method is called by children processes right after forking. More...
 
TMPWorkeroperator= (const TMPWorker &)=delete
 
void Run ()
 

Private Attributes

std::vector< T > fArgs
 a vector containing the arguments that must be passed to fFunc More...
 
bool fCanReduce
 true if fReducedResult can be reduced with a new result, false until we have produced one result More...
 
F fFunc
 the function to be executed More...
 
R fRedFunc
 the reduce function More...
 
decltype(fFunc(fArgs.front())) fReducedResult
 the result of the execution More...
 

Additional Inherited Members

- Protected Member Functions inherited from TMPWorker
void SendError (const std::string &errmsg, unsigned int code=MPCode::kError)
 Error sender. More...
 
- Protected Attributes inherited from TMPWorker
std::string fId
 identifier string in the form W<nwrk>|P<proc id> More...
 
ULong64_t fMaxNEntries
 the maximum number of entries to be processed by this worker More...
 
unsigned fNWorkers
 the number of workers spawned More...
 
ULong64_t fProcessedEntries
 the number of entries processed by this worker so far More...
 

#include <TMPWorkerExecutor.h>

Inheritance diagram for TMPWorkerExecutor< F, T, R >:
[legend]

Constructor & Destructor Documentation

◆ TMPWorkerExecutor()

template<class F , class T = void, class R = void>
TMPWorkerExecutor< F, T, R >::TMPWorkerExecutor ( F  func,
const std::vector< T > &  args,
R  redfunc 
)
inline

Definition at line 82 of file TMPWorkerExecutor.h.

◆ ~TMPWorkerExecutor()

template<class F , class T = void, class R = void>
TMPWorkerExecutor< F, T, R >::~TMPWorkerExecutor ( )
inline

Definition at line 86 of file TMPWorkerExecutor.h.

Member Function Documentation

◆ HandleInput()

template<class F , class T = void, class R = void>
void TMPWorkerExecutor< F, T, R >::HandleInput ( MPCodeBufPair msg)
inlinevirtual

Handle a message with an EMPCode.

This method is called upon receiving a message with a code >= 1000 (i.e. EMPCode). It handles the most generic types of messages.
Classes inheriting from TMPWorker should implement their own HandleInput function, that should be able to handle codes specific to that application.
The appropriate version of the HandleInput method (TMPWorker's or the overriding version) is automatically called depending on the message code.

Reimplemented from TMPWorker.

Definition at line 88 of file TMPWorkerExecutor.h.

Member Data Documentation

◆ fArgs

template<class F , class T = void, class R = void>
std::vector<T> TMPWorkerExecutor< F, T, R >::fArgs
private

a vector containing the arguments that must be passed to fFunc

Definition at line 119 of file TMPWorkerExecutor.h.

◆ fCanReduce

template<class F , class T = void, class R = void>
bool TMPWorkerExecutor< F, T, R >::fCanReduce
private

true if fReducedResult can be reduced with a new result, false until we have produced one result

Definition at line 122 of file TMPWorkerExecutor.h.

◆ fFunc

template<class F , class T = void, class R = void>
F TMPWorkerExecutor< F, T, R >::fFunc
private

the function to be executed

Definition at line 118 of file TMPWorkerExecutor.h.

◆ fRedFunc

template<class F , class T = void, class R = void>
R TMPWorkerExecutor< F, T, R >::fRedFunc
private

the reduce function

Definition at line 120 of file TMPWorkerExecutor.h.

◆ fReducedResult

template<class F , class T = void, class R = void>
decltype(fFunc(fArgs.front())) TMPWorkerExecutor< F, T, R >::fReducedResult
private

the result of the execution

Definition at line 121 of file TMPWorkerExecutor.h.

Libraries for TMPWorkerExecutor< F, T, R >:
[legend]

The documentation for this class was generated from the following file: