ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes | List of all members
TPoolWorker< F, T, R > Class Template Reference

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

This class works together with TProcPool 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.

TPoolWorker<F, T, R>

The most general case, used by TProcPool::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 TPoolWorker at construction time, the kind of messages that client and workers have to exchange are usually very simple.

Definition at line 40 of file TPoolWorker.h.

Public Member Functions

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

Private Attributes

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

#include <TPoolWorker.h>

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

Constructor & Destructor Documentation

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

Definition at line 45 of file TPoolWorker.h.

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

Definition at line 49 of file TPoolWorker.h.

Member Function Documentation

template<class F, class T = void, class R = void>
void TPoolWorker< 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.

Parameters
msgExecute instructions received from a TProcPool client

Reimplemented from TMPWorker.

Definition at line 51 of file TPoolWorker.h.

Member Data Documentation

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

a vector containing the arguments that must be passed to fFunc

Definition at line 80 of file TPoolWorker.h.

Referenced by TPoolWorker< F, T, R >::HandleInput(), and TPoolWorker< F, T, void >::HandleInput().

template<class F, class T = void, class R = void>
bool TPoolWorker< 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 83 of file TPoolWorker.h.

Referenced by TPoolWorker< F, T, R >::HandleInput().

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

the reduce function

Definition at line 81 of file TPoolWorker.h.

Referenced by TPoolWorker< F, T, R >::HandleInput(), and TPoolWorker< F, void, R >::HandleInput().

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

the result of the execution

Definition at line 82 of file TPoolWorker.h.

Referenced by TPoolWorker< F, T, R >::HandleInput(), and TPoolWorker< F, void, R >::HandleInput().

Collaboration diagram for TPoolWorker< F, T, R >:
[legend]

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