11#ifndef __BE_PROCESS_FORKMANAGER_H__
12#define __BE_PROCESS_FORKMANAGER_H__
25 class ForkWorkerController;
63 std::shared_ptr<WorkerController>
65 std::shared_ptr<Worker> worker);
86 bool communicate =
false);
109 std::shared_ptr<WorkerController> worker,
111 bool communicate =
false);
138 std::shared_ptr<WorkerController> workerController);
229 (std::shared_ptr<ForkWorkerController> worker,
247 std::shared_ptr<ForkWorkerController> worker,
269 const int32_t waitStatus);
286 std::shared_ptr<ForkWorkerController>
343 (std::shared_ptr<ForkWorkerController> wc,
351 std::shared_ptr<ForkWorkerController>, Status>
437 std::shared_ptr<Worker> worker);
458 bool communicate =
false);
480 static std::shared_ptr<Worker> _staticWorker;
528 std::shared_ptr<WorkerController> worker,
550 std::shared_ptr<WorkerController> workerController);
562 friend std::shared_ptr<WorkerController>
564 std::shared_ptr<Worker> worker);
585 const int32_t waitStatus);
Manager implementation that starts Workers by calling fork(2).
bool getIsWorkingStatus(const pid_t pid) const
Get Status.isWorking for PID.
void broadcastSignal(int signo)
Send a POSIX signal to all workers.
void stopWorker(std::shared_ptr< WorkerController > workerController)
Ask Worker to exit.
static void defaultExitCallback(std::shared_ptr< ForkWorkerController > worker, int status)
A default exit callback function.
static std::list< ForkManager * > FORKMANAGERS
List of all instantiated ForkManagers.
void startWorker(std::shared_ptr< WorkerController > worker, bool wait=true, bool communicate=false)
Start a worker.
bool responsibleFor(const pid_t pid) const
Obtain whether or not this ForkManager is responsbile for a particular PID.
void setExitCallback(void(*exitCallback)(std::shared_ptr< ForkWorkerController > worker, int stat_loc))
Call a function in your program when a child exits.
void setExitStatus(const pid_t pid, const int32_t waitStatus)
Set the exit status in the WorkerController for given process ID.
void setNotWorking(const pid_t pid)
Set Status.isWorking for PID to false.
void startWorkers(bool wait=true, bool communicate=false)
Begin Worker's work.
~ForkManager()
ForkManager destructor.
void waitForWorkerExit()
Block until all Workers have exited.
void markAllFinished()
Call setNotWorking() for all PIDs known to this ForkManager.
std::shared_ptr< WorkerController > addWorker(std::shared_ptr< Worker > worker)
Adds a Worker to be managed by this Manager.
ForkManager()
ForkManager constructor.
Wrapper of a Worker returned from a Process::ForkManager.
static void _stop(int signal)
Tell _staticWorker to stop.
void reset()
Reuse the Worker.
pid_t getPID() const
Obtain the PID of this process this instance represents.
bool isWorking() const
Obtain whether or not Worker is working.
bool everWorked() const
Obtain whether or not this Worker has ever worked.
~ForkWorkerController()
ForkWorkerController destructor.
An interface for intranode process management classes.
Wrapper of a Worker returned from a Process::Manager.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...