Definition at line 128 of file TMPWorkerExecutor.h.
Public Member Functions | |
| TMPWorkerExecutor (F func, R redfunc) | |
| ~TMPWorkerExecutor () | |
| unsigned | GetNWorker () const |
| pid_t | GetPid () |
| TSocket * | GetSocket () |
| void | HandleInput (MPCodeBufPair &msg) |
| Handle a message with an EMPCode. | |
| 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< void > | 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 | |
| R | fRedFunc |
| the reduce function | |
| decltype(fFunc()) | fReducedResult |
| the result of the execution | |
| std::unique_ptr< TSocket > | fS |
| This worker's socket. The unique_ptr makes sure resources are released. | |
#include <TMPWorkerExecutor.h>
|
inline |
Definition at line 130 of file TMPWorkerExecutor.h.
|
inline |
Definition at line 134 of file TMPWorkerExecutor.h.
|
inline |
Definition at line 41 of file TMPWorker.h.
|
inline |
Definition at line 40 of file TMPWorker.h.
|
inline |
Definition at line 39 of file TMPWorker.h.
|
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 136 of file TMPWorkerExecutor.h.
|
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.
| void TMPWorker::Run | ( | ) |
Definition at line 38 of file TMPWorker.cxx.
|
protected |
Error sender.
Definition at line 49 of file TMPWorker.cxx.
|
private |
a vector containing the arguments that must be passed to fFunc
Definition at line 120 of file TMPWorkerExecutor.h.
true if fReducedResult can be reduced with a new result, false until we have produced one result
Definition at line 165 of file TMPWorkerExecutor.h.
the function to be executed
Definition at line 162 of file TMPWorkerExecutor.h.
|
protected |
identifier string in the form W<nwrk>|P<proc id>
Definition at line 44 of file TMPWorker.h.
|
protected |
the maximum number of entries to be processed by this worker
Definition at line 46 of file TMPWorker.h.
|
private |
the ordinal number of this worker (0 to nWorkers-1)
Definition at line 56 of file TMPWorker.h.
|
protected |
the number of workers spawned
Definition at line 45 of file TMPWorker.h.
|
private |
the PID of the process in which this worker is running
Definition at line 55 of file TMPWorker.h.
|
protected |
the number of entries processed by this worker so far
Definition at line 47 of file TMPWorker.h.
the reduce function
Definition at line 163 of file TMPWorkerExecutor.h.
|
private |
the result of the execution
Definition at line 164 of file TMPWorkerExecutor.h.
|
private |
This worker's socket. The unique_ptr makes sure resources are released.
Definition at line 54 of file TMPWorker.h.