Belle II Software  release-08-01-10
GlobalProcHandler Class Reference

A class to manage processes for parallel processing. More...

#include <GlobalProcHandler.h>

Collaboration diagram for GlobalProcHandler:

Static Public Member Functions

static void initialize (unsigned int nWorkerProc)
 Create a new process handler, which will handle nWorkerProc processes.
 
static bool startInputProcess ()
 Fork and initialize an input process.
 
static bool startWorkerProcesses (unsigned int numProcesses)
 Fork and initialize as many worker processes as requested.
 
static bool startOutputProcess (bool local=false)
 Fork and initialize an output process. More...
 
static bool startProxyProcess ()
 Fork and initialize a proxy process.
 
static bool startMonitoringProcess ()
 Fork and initialize a monitoring process.
 
static void waitForAllProcesses ()
 Wait until all forked processes handled by this GlobalProcHandler.
 
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 of type c_Input.
 
static bool isWorkerProcess ()
 Return true if the process is of type c_Worker.
 
static bool isOutputProcess ()
 Return true if the process is of type c_Output.
 
static int numEventProcesses ()
 Return number of worker processes (configured value, not current)
 
static int EvtProcID ()
 Get the ID of this process. Attention: this ID may not be a stable API feature.
 
static std::string getProcessName ()
 Get a human readable name for this process. (input, event, output...).
 
static void killAllProcesses ()
 Hard kill all processes.
 
static const std::vector< int > & getPIDList ()
 Return the PID list handled by the running GlobalProcHandler. This PID list is updated using the signal handlers and the startup of processes.
 
static bool isProcess (ProcType procType)
 Return true if the process is of type procType.
 
static ProcType getProcType (int pid)
 Return the proc type of this process.
 

Static Private Member Functions

static bool startProc (ProcType procType, int id)
 Start a new process, sets the type and id and returns true if in this new process. More...
 
static void addPID (int pid)
 Add a new PID. Is called when forking.
 
static bool findPID (int pid)
 Find a PID in the list and return true, if found.
 
static void removePID (int pid)
 Remove a PID from the list by setting it to 0.
 
static void clearPIDs ()
 Remove all PIDs.
 
static bool pidListEmpty ()
 Check if the PID list is empty (only 0).
 
static void childSignalHandler (int)
 This function is called on SIG_CLD.
 

Static Private Attributes

static ProcType s_procType = ProcType::c_Init
 Our current proc type.
 
static int s_processID = -1
 Our current process id.
 
static int s_numEventProcesses = 0
 How many processes are handled in this GlobalProcHandler.
 
static std::vector< int > s_pidVector
 global list of PIDs managed by GlobalProcHandler.
 
static std::map< int, ProcTypes_startedPIDs
 Which PIDs were started with which types.
 

Detailed Description

A class to manage processes for parallel processing.

Definition at line 22 of file GlobalProcHandler.h.

Member Function Documentation

◆ startOutputProcess()

bool startOutputProcess ( bool  local = false)
static

Fork and initialize an output process.

If local is true, do not fork.

Definition at line 156 of file GlobalProcHandler.cc.

157 {
158  if (local) {
160  return true;
161  } else {
162  return (startProc(ProcType::c_Output, 20000));
163  }
164 }
static bool startProc(ProcType procType, int id)
Start a new process, sets the type and id and returns true if in this new process.
static ProcType s_procType
Our current proc type.
@ c_Output
Output Process.

◆ startProc()

bool startProc ( ProcType  procType,
int  id 
)
staticprivate

Start a new process, sets the type and id and returns true if in this new process.

Also adds the signal handling.

Definition at line 182 of file GlobalProcHandler.cc.


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