Belle II Software light-2406-ragdoll
|
A class to manage processes for parallel processing. More...
#include <ProcHandler.h>
Public Member Functions | |
ProcHandler (unsigned int nWorkerProc, bool markChildrenAsLocal=false) | |
Constructor. | |
~ProcHandler () | |
Destructor. | |
void | startInputProcess () |
Fork and initialize an input process. | |
void | startWorkerProcesses () |
Fork and initialize worker processes. | |
void | startOutputProcess () |
There is no real output process, but marks current process as output. | |
bool | waitForAllProcesses () |
Wait until all forked processes handled by this ProcHandler terminate. | |
std::set< int > | processList () const |
Return list of PIDs managed by this ProcHandler instance. | |
Static Public Member Functions | |
static bool | parallelProcessingUsed () |
Returns true if multiple processes have been spawned, false in single-core mode. | |
static bool | isInputProcess () |
Return true if the process is an input process. | |
static bool | isWorkerProcess () |
Return true if the process is a worker process. | |
static bool | isOutputProcess () |
Return true if the process is an output process. | |
static int | numEventProcesses () |
Return number of worker processes (configured value, not current) | |
static std::set< int > | globalProcessList () |
Return list of all PIDs (from all ProcHandler instances). | |
static int | EvtProcID () |
Return ID of the current process. | |
static void | setProcessID (int processID) |
Set the process ID of this process. | |
static std::string | getProcessName () |
Get a name for this process. | |
Private Member Functions | |
bool | startProc (std::set< int > *processList, const std::string &procType, int id) |
Start a new process, adding its PID to processList, and setting s_processID = id. | |
Private Attributes | |
bool | m_markChildrenAsLocal |
Anormal termination of child will not stop parent, waitForAllProcesses() returns status. | |
std::set< int > | m_processList |
PIDs of processes controlled by this ProcHandler. | |
unsigned int | m_numWorkerProcesses |
Number of worker processes controlled by this ProcHandler. | |
A class to manage processes for parallel processing.
Definition at line 21 of file ProcHandler.h.
|
explicit |
Constructor.
Children marked as local will not cause the parent process to die in case of anormal termination. Errors can be detected using the return value of waitForAllProcesses(). Note that you probably shouldn't have multiple ProcHandlers with local children running at the same time.
Definition at line 188 of file ProcHandler.cc.
|
static |
Return ID of the current process.
Return values mean: -1: no parallel processing used <10000 one of the worker processes (between input and output paths). In range 0..Environment::getInstance().getNumberProcesses()-1. >=10000 input path >=20000 output path
Definition at line 248 of file ProcHandler.cc.
|
static |
Get a name for this process.
(input, event, output...).
Definition at line 252 of file ProcHandler.cc.
|
static |
Return list of all PIDs (from all ProcHandler instances).
Definition at line 239 of file ProcHandler.cc.
|
static |
Return true if the process is an input process.
Definition at line 228 of file ProcHandler.cc.
|
static |
Return true if the process is an output process.
Definition at line 232 of file ProcHandler.cc.
|
static |
Return true if the process is a worker process.
Definition at line 230 of file ProcHandler.cc.
|
static |
Return number of worker processes (configured value, not current)
Definition at line 234 of file ProcHandler.cc.
|
static |
Returns true if multiple processes have been spawned, false in single-core mode.
Definition at line 226 of file ProcHandler.cc.
std::set< int > processList | ( | ) | const |
Return list of PIDs managed by this ProcHandler instance.
Definition at line 243 of file ProcHandler.cc.
|
static |
Set the process ID of this process.
Definition at line 250 of file ProcHandler.cc.
void startInputProcess | ( | ) |
Fork and initialize an input process.
Definition at line 207 of file ProcHandler.cc.
void startOutputProcess | ( | ) |
There is no real output process, but marks current process as output.
Definition at line 220 of file ProcHandler.cc.
|
private |
Start a new process, adding its PID to processList, and setting s_processID = id.
Returns true in child process.
Definition at line 154 of file ProcHandler.cc.
void startWorkerProcesses | ( | ) |
Fork and initialize worker processes.
Definition at line 212 of file ProcHandler.cc.
bool waitForAllProcesses | ( | ) |
Wait until all forked processes handled by this ProcHandler terminate.
In case the markChildrenAsLocal option was set when a process was started and this process terminated anormaly (via signal or non-zero exit code), the return value is set to false. Otherwise, true is returned.
Definition at line 266 of file ProcHandler.cc.
|
private |
Anormal termination of child will not stop parent, waitForAllProcesses() returns status.
Definition at line 88 of file ProcHandler.h.
|
private |
Number of worker processes controlled by this ProcHandler.
Definition at line 90 of file ProcHandler.h.
|
private |
PIDs of processes controlled by this ProcHandler.
Definition at line 89 of file ProcHandler.h.