|
NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
|
Manager implementation that starts Workers by calling fork(2). More...
#include <be_process_forkmanager.h>
Inherits BiometricEvaluation::Process::Manager.
Public Member Functions | |
| ForkManager () | |
| ForkManager constructor. More... | |
| std::shared_ptr< WorkerController > | addWorker (std::shared_ptr< Worker > worker) |
| Adds a Worker to be managed by this Manager. More... | |
| void | startWorkers (bool wait=true, bool communicate=false) |
| Begin Worker's work. More... | |
| void | startWorker (std::shared_ptr< WorkerController > worker, bool wait=true, bool communicate=false) |
| Start a worker. More... | |
| void | stopWorker (std::shared_ptr< WorkerController > workerController) |
| Ask Worker to exit. More... | |
| void | broadcastSignal (int signo) |
| Send a POSIX signal to all workers. More... | |
| bool | responsibleFor (const pid_t pid) const |
| Obtain whether or not this ForkManager is responsbile for a particular PID. More... | |
| void | setNotWorking (const pid_t pid) |
| Set Status.isWorking for PID to false. More... | |
| void | markAllFinished () |
| Call setNotWorking() for all PIDs known to this ForkManager. More... | |
| bool | getIsWorkingStatus (const pid_t pid) const |
| Get Status.isWorking for PID. More... | |
| void | waitForWorkerExit () |
| Block until all Workers have exited. More... | |
| ~ForkManager () | |
| ForkManager destructor. More... | |
| void | setExitCallback (void(*exitCallback)(std::shared_ptr< ForkWorkerController > worker, int stat_loc)) |
| Call a function in your program when a child exits. More... | |
| void | setExitStatus (const pid_t pid, const int32_t waitStatus) |
| Set the exit status in the WorkerController for given process ID. More... | |
Public Member Functions inherited from BiometricEvaluation::Process::Manager | |
| Manager () | |
| Manager constructor. More... | |
| virtual std::shared_ptr< WorkerController > | addWorker (std::shared_ptr< Worker > worker)=0 |
| Adds a Worker to be managed by this Manager. More... | |
| virtual uint32_t | getNumCompletedWorkers () const |
| Obtain the number of Workers that have exited. More... | |
| virtual uint32_t | getNumActiveWorkers () const |
| Obtain the number of Workers that are still working. More... | |
| virtual uint32_t | getTotalWorkers () const |
| Obtain the number of Workers this class is handling. More... | |
| virtual void | startWorkers (bool wait=true, bool communicate=false)=0 |
| Begin Worker's work. More... | |
| virtual void | startWorker (std::shared_ptr< WorkerController > worker, bool wait=true, bool communicate=false)=0 |
| Start a Worker. More... | |
| virtual void | waitForWorkerExit ()=0 |
| Block until all Workers have exited. More... | |
| virtual void | reset () |
| Reuse all Workers. More... | |
| virtual void | stopWorker (std::shared_ptr< WorkerController > worker)=0 |
| Ask Worker to return as soon as possible. More... | |
| virtual bool | waitForMessage (std::shared_ptr< WorkerController > &sender, int *nextFD=nullptr, int numSeconds=-1) const |
| Wait for a message from a Worker. More... | |
| virtual bool | getNextMessage (std::shared_ptr< WorkerController > &sender, Memory::uint8Array &message, int numSeconds=-1) const |
| Obtain a message from a Worker. More... | |
| virtual void | broadcastMessage (Memory::uint8Array &message) const |
| Send one message to all Workers. More... | |
| virtual | ~Manager () |
| Manager destructor. More... | |
Static Public Member Functions | |
| static void | defaultExitCallback (std::shared_ptr< ForkWorkerController > worker, int status) |
| A default exit callback function. More... | |
Static Public Attributes | |
| static std::list< ForkManager * > | FORKMANAGERS |
| List of all instantiated ForkManagers. More... | |
Additional Inherited Members | |
| virtual void | _wait ()=0 |
| Do not return until all spawned processes exited. More... | |
Protected Attributes inherited from BiometricEvaluation::Process::Manager | |
| std::vector< std::shared_ptr< WorkerController > > | _workers |
| Workers that have been added. More... | |
| std::vector< std::shared_ptr< WorkerController > > | _pendingExit |
| Workers that are about to exit (stop requested). More... | |
Manager implementation that starts Workers by calling fork(2).
Definition at line 32 of file be_process_forkmanager.h.
| BiometricEvaluation::Process::ForkManager::ForkManager | ( | ) |
ForkManager constructor.
| BiometricEvaluation::Process::ForkManager::~ForkManager | ( | ) |
ForkManager destructor.
|
virtual |
Adds a Worker to be managed by this Manager.
| worker | A Worker instance to run. |
Implements BiometricEvaluation::Process::Manager.
|
virtual |
Begin Worker's work.
| [in] | wait | Whether or not to wait for all Workers to return before returning. |
| [in] | communicate | Whether or not to enable communication among the Workers and Managers. |
| Error::ObjectExists | At least one Worker is already working. |
| Error::StrategyError | Problem forking. |
Implements BiometricEvaluation::Process::Manager.
|
virtual |
Start a worker.
| worker | Pointer to a WorkerController that is being managed by this Manager instance. | |
| wait | Whether or not to wait for this Worker to exit before returning control to the caller. | |
| [in] | communicate | Whether or not to enable communication among the Workers and Managers. |
| Error::ObjectExists | worker is already working. |
| Error::StrategyError | worker is not managed by this Manager instance. |
Implements BiometricEvaluation::Process::Manager.
|
virtual |
Ask Worker to exit.
Sends SIGUSR1 to the Worker, which ForkManager will handle automatically.
| workerController | Pointer to the ForkWorkerController that should be stopped. |
| Error::ObjectDoesNotExist | worker is not working. |
| Error::StrategyError | Problem sending the signal. |
Implements BiometricEvaluation::Process::Manager.
| void BiometricEvaluation::Process::ForkManager::broadcastSignal | ( | int | signo | ) |
Send a POSIX signal to all workers.
| [in] | signo | The signal to send. |
| bool BiometricEvaluation::Process::ForkManager::responsibleFor | ( | const pid_t | pid | ) | const |
Obtain whether or not this ForkManager is responsbile for a particular PID.
| [in] | pid | PID in question |
| void BiometricEvaluation::Process::ForkManager::setNotWorking | ( | const pid_t | pid | ) |
Set Status.isWorking for PID to false.
| [in] | pid | PID whose inWorking flag should be set to false |
| Error::ObjectDoesNotExist | PID not under this manager's control. |
| void BiometricEvaluation::Process::ForkManager::markAllFinished | ( | ) |
Call setNotWorking() for all PIDs known to this ForkManager.
| bool BiometricEvaluation::Process::ForkManager::getIsWorkingStatus | ( | const pid_t | pid | ) | const |
Get Status.isWorking for PID.
| [in] | pid | PID whose inWorking flag should be queried |
| Error::ObjectDoesNotExist | PID not under this manager's control. |
|
virtual |
Block until all Workers have exited.
Use this method if wait=false was set during a call to startWorker(s) but now wait=true is desired.
Implements BiometricEvaluation::Process::Manager.
| void BiometricEvaluation::Process::ForkManager::setExitCallback | ( | void(*)(std::shared_ptr< ForkWorkerController > worker, int stat_loc) | exitCallback | ) |
Call a function in your program when a child exits.
| exitCallback | Function pointer to a method that takes a shared_ptr to a ForkWorkerController and the integer status information. |
|
static |
A default exit callback function.
Writes to stdout in the form: PID #: Exited .
| worker | The ForkWorkerController object that exited. |
| status | The status of the Worker that exited (from wait(2)). |
| void BiometricEvaluation::Process::ForkManager::setExitStatus | ( | const pid_t | pid, |
| const int32_t | waitStatus | ||
| ) |
Set the exit status in the WorkerController for given process ID.
| [in] | pid | PID whose exit status should be set. |
| [in] | status | Status, as returned from wait(2). |
| Error::ObjectDoesNotExist | PID not under this manager's control. |
|
static |
List of all instantiated ForkManagers.
This is not a list of managed pointers to ForkManagers. If it was, the smart pointer's destructor would attempt to delete the object being pointed to at program termination, which is ultimately sometime after the destructor of the ForkManager itself was called.
Definition at line 46 of file be_process_forkmanager.h.