Fork processes for queue and workers.
This class manages three types of processes:
N_workers | Number of worker processes to spawn. |
Definition at line 26 of file ProcessManager.h.
Public Member Functions | |
ProcessManager (std::size_t N_workers) | |
~ProcessManager () | |
pid_t | get_queue_pid () const |
std::vector< pid_t > | get_worker_pids () |
void | identify_processes () const |
Print to stdout which type of process we are on and what its PID is (for debugging) | |
bool | is_initialized () const |
bool | is_master () const |
bool | is_queue () const |
bool | is_worker () const |
std::size_t | N_workers () const |
void | terminate () noexcept |
Shutdown forked processes if on master and if this process manager is initialized. | |
void | wait_for_sigterm_then_exit () |
std::size_t | worker_id () const |
Static Public Member Functions | |
static void | handle_sigterm (int signum) |
We need this to tell the children to die, because we can't talk to them anymore during JobManager destruction, because that kills the Messenger first. | |
static bool | sigterm_received () |
Private Member Functions | |
void | initialize_processes (bool cpu_pinning=true) |
Fork processes and activate CPU pinning. | |
void | shutdown_processes () |
Shutdown forked processes if on master. | |
Private Attributes | |
bool | initialized_ = false |
bool | is_master_ = false |
bool | is_queue_ = false |
bool | is_worker_ = false |
std::size_t | N_workers_ |
friend | Queue |
pid_t | queue_pid_ |
std::size_t | worker_id_ |
std::vector< pid_t > | worker_pids_ |
Static Private Attributes | |
static volatile sig_atomic_t | sigterm_received_ = 0 |
|
explicit |
Definition at line 41 of file ProcessManager.cxx.
RooFit::MultiProcess::ProcessManager::~ProcessManager | ( | ) |
Definition at line 58 of file ProcessManager.cxx.
|
inline |
Definition at line 50 of file ProcessManager.h.
|
inline |
Definition at line 51 of file ProcessManager.h.
|
static |
We need this to tell the children to die, because we can't talk to them anymore during JobManager destruction, because that kills the Messenger first.
We do that with SIGTERMs. The sigterm_received() should be checked in message loops to stop them when it's true.
Definition at line 75 of file ProcessManager.cxx.
void RooFit::MultiProcess::ProcessManager::identify_processes | ( | ) | const |
Print to stdout which type of process we are on and what its PID is (for debugging)
Definition at line 318 of file ProcessManager.cxx.
|
private |
Fork processes and activate CPU pinning.
cpu_pinning | Activate CPU pinning if true. Effective on Linux only. |
Definition at line 111 of file ProcessManager.cxx.
bool RooFit::MultiProcess::ProcessManager::is_initialized | ( | ) | const |
Definition at line 204 of file ProcessManager.cxx.
bool RooFit::MultiProcess::ProcessManager::is_master | ( | ) | const |
Definition at line 292 of file ProcessManager.cxx.
bool RooFit::MultiProcess::ProcessManager::is_queue | ( | ) | const |
Definition at line 297 of file ProcessManager.cxx.
bool RooFit::MultiProcess::ProcessManager::is_worker | ( | ) | const |
Definition at line 302 of file ProcessManager.cxx.
std::size_t RooFit::MultiProcess::ProcessManager::N_workers | ( | ) | const |
Definition at line 312 of file ProcessManager.cxx.
|
private |
Shutdown forked processes if on master.
Definition at line 266 of file ProcessManager.cxx.
|
static |
Definition at line 81 of file ProcessManager.cxx.
|
noexcept |
Shutdown forked processes if on master and if this process manager is initialized.
Definition at line 210 of file ProcessManager.cxx.
void RooFit::MultiProcess::ProcessManager::wait_for_sigterm_then_exit | ( | ) |
Definition at line 222 of file ProcessManager.cxx.
std::size_t RooFit::MultiProcess::ProcessManager::worker_id | ( | ) | const |
Definition at line 307 of file ProcessManager.cxx.
|
private |
Definition at line 67 of file ProcessManager.h.
|
private |
Definition at line 57 of file ProcessManager.h.
|
private |
Definition at line 58 of file ProcessManager.h.
|
private |
Definition at line 59 of file ProcessManager.h.
|
private |
Definition at line 61 of file ProcessManager.h.
|
private |
Definition at line 27 of file ProcessManager.h.
|
private |
Definition at line 65 of file ProcessManager.h.
|
staticprivate |
Definition at line 69 of file ProcessManager.h.
|
private |
Definition at line 60 of file ProcessManager.h.
|
private |
Definition at line 64 of file ProcessManager.h.