Belle II Software light-2406-ragdoll
ProcHandler.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <set>
12#include <string>
13
14namespace Belle2 {
22 public:
31 explicit ProcHandler(unsigned int nWorkerProc, bool markChildrenAsLocal = false);
34
36 void startInputProcess();
40 void startOutputProcess();
41
49
51 static bool parallelProcessingUsed();
53 static bool isInputProcess();
55 static bool isWorkerProcess();
57 static bool isOutputProcess();
58
59
61 static int numEventProcesses();
62
64 std::set<int> processList() const;
66 static std::set<int> globalProcessList();
67
76 static int EvtProcID();
77
79 static void setProcessID(int processID);
80
82 static std::string getProcessName();
83
84 private:
86 bool startProc(std::set<int>* processList, const std::string& procType, int id);
87
89 std::set<int> m_processList;
90 unsigned int m_numWorkerProcesses;
91 };
93}
A class to manage processes for parallel processing.
Definition: ProcHandler.h:21
void startOutputProcess()
There is no real output process, but marks current process as output.
Definition: ProcHandler.cc:220
static bool isWorkerProcess()
Return true if the process is a worker process.
Definition: ProcHandler.cc:230
static int EvtProcID()
Return ID of the current process.
Definition: ProcHandler.cc:248
std::set< int > m_processList
PIDs of processes controlled by this ProcHandler.
Definition: ProcHandler.h:89
static int numEventProcesses()
Return number of worker processes (configured value, not current)
Definition: ProcHandler.cc:234
static bool isOutputProcess()
Return true if the process is an output process.
Definition: ProcHandler.cc:232
static bool isInputProcess()
Return true if the process is an input process.
Definition: ProcHandler.cc:228
static void setProcessID(int processID)
Set the process ID of this process.
Definition: ProcHandler.cc:250
unsigned int m_numWorkerProcesses
Number of worker processes controlled by this ProcHandler.
Definition: ProcHandler.h:90
static std::set< int > globalProcessList()
Return list of all PIDs (from all ProcHandler instances).
Definition: ProcHandler.cc:239
bool waitForAllProcesses()
Wait until all forked processes handled by this ProcHandler terminate.
Definition: ProcHandler.cc:266
static bool parallelProcessingUsed()
Returns true if multiple processes have been spawned, false in single-core mode.
Definition: ProcHandler.cc:226
bool m_markChildrenAsLocal
Anormal termination of child will not stop parent, waitForAllProcesses() returns status.
Definition: ProcHandler.h:88
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.
Definition: ProcHandler.cc:154
~ProcHandler()
Destructor.
void startWorkerProcesses()
Fork and initialize worker processes.
Definition: ProcHandler.cc:212
std::set< int > processList() const
Return list of PIDs managed by this ProcHandler instance.
Definition: ProcHandler.cc:243
void startInputProcess()
Fork and initialize an input process.
Definition: ProcHandler.cc:207
static std::string getProcessName()
Get a name for this process.
Definition: ProcHandler.cc:252
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24