Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TMPWorkerExecutor< F, T, void > Class Template Reference

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

Definition at line 169 of file TMPWorkerExecutor.h.

Public Member Functions

 TMPWorkerExecutor (F func, const std::vector< T > &args)
 ~TMPWorkerExecutor ()
unsigned GetNWorker () const
pid_t GetPid ()
TSocketGetSocket ()
void HandleInput (MPCodeBufPair &msg) override
 < Execute instructions received from a TProcessExecutor client
virtual void Init (int fd, unsigned workerN)
 This method is called by children processes right after forking.
void Run ()

Protected Member Functions

void SendError (const std::string &errmsg, unsigned int code=MPCode::kError)
 Error sender.

Protected Attributes

std::string fId
 identifier string in the form W<nwrk>|P<proc id>
ULong64_t fMaxNEntries
 the maximum number of entries to be processed by this worker
unsigned fNWorkers
 the number of workers spawned
ULong64_t fProcessedEntries
 the number of entries processed by this worker so far

Private Attributes

std::vector< T > fArgs
 a vector containing the arguments that must be passed to fFunc
bool fCanReduce
 true if fReducedResult can be reduced with a new result, false until we have produced one result
F fFunc
 the function to be executed
unsigned fNWorker
 the ordinal number of this worker (0 to nWorkers-1)
pid_t fPid
 the PID of the process in which this worker is running
void fRedFunc
 the reduce function
decltype(fFunc(fArgs.front())) fReducedResult
 the result of the execution
std::unique_ptr< TSocketfS
 This worker's socket. The unique_ptr makes sure resources are released.

#include <TMPWorkerExecutor.h>

Inheritance diagram for TMPWorkerExecutor< F, T, void >:
TMPWorker TMPWorker

Constructor & Destructor Documentation

◆ TMPWorkerExecutor()

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

Definition at line 171 of file TMPWorkerExecutor.h.

◆ ~TMPWorkerExecutor()

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

Definition at line 172 of file TMPWorkerExecutor.h.

Member Function Documentation

◆ GetNWorker()

unsigned TMPWorker::GetNWorker ( ) const
inline

Definition at line 41 of file TMPWorker.h.

◆ GetPid()

pid_t TMPWorker::GetPid ( )
inline

Definition at line 40 of file TMPWorker.h.

◆ GetSocket()

Definition at line 39 of file TMPWorker.h.

◆ HandleInput()

template<class F, class T>
void TMPWorkerExecutor< F, T, void >::HandleInput ( MPCodeBufPair & msg)
inlineoverridevirtual

< Execute instructions received from a TProcessExecutor client

Reimplemented from TMPWorker.

Definition at line 173 of file TMPWorkerExecutor.h.

◆ Init()

void TMPWorker::Init ( int fd,
unsigned workerN )
virtual

This method is called by children processes right after forking.

Initialization of worker properties that must be delayed until after forking must be done here.
For example, Init saves the pid into fPid, and adds the TMPWorker to the main eventloop (as a TFileHandler).
Make sure this operations are performed also by overriding implementations, e.g. by calling TMPWorker::Init explicitly.

Definition at line 37 of file TMPWorker.cxx.

◆ Run()

void TMPWorker::Run ( )

Definition at line 38 of file TMPWorker.cxx.

◆ SendError()

void TMPWorker::SendError ( const std::string & errmsg,
unsigned int code = MPCode::kError )
protected

Error sender.

Definition at line 49 of file TMPWorker.cxx.

Member Data Documentation

◆ fArgs

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

a vector containing the arguments that must be passed to fFunc

Definition at line 189 of file TMPWorkerExecutor.h.

◆ fCanReduce

bool TMPWorkerExecutor< F, T, void >::fCanReduce
private

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

Definition at line 123 of file TMPWorkerExecutor.h.

◆ fFunc

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

the function to be executed

Definition at line 188 of file TMPWorkerExecutor.h.

◆ fId

std::string TMPWorker::fId
protected

identifier string in the form W<nwrk>|P<proc id>

Definition at line 44 of file TMPWorker.h.

◆ fMaxNEntries

the maximum number of entries to be processed by this worker

Definition at line 46 of file TMPWorker.h.

◆ fNWorker

unsigned TMPWorker::fNWorker
private

the ordinal number of this worker (0 to nWorkers-1)

Definition at line 56 of file TMPWorker.h.

◆ fNWorkers

unsigned TMPWorker::fNWorkers
protected

the number of workers spawned

Definition at line 45 of file TMPWorker.h.

◆ fPid

pid_t TMPWorker::fPid
private

the PID of the process in which this worker is running

Definition at line 55 of file TMPWorker.h.

◆ fProcessedEntries

the number of entries processed by this worker so far

Definition at line 47 of file TMPWorker.h.

◆ fRedFunc

void TMPWorkerExecutor< F, T, void >::fRedFunc
private

the reduce function

Definition at line 121 of file TMPWorkerExecutor.h.

◆ fReducedResult

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

the result of the execution

Definition at line 122 of file TMPWorkerExecutor.h.

◆ fS

std::unique_ptr<TSocket> TMPWorker::fS
private

This worker's socket. The unique_ptr makes sure resources are released.

Definition at line 54 of file TMPWorker.h.


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