NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BiometricEvaluation::Process::Manager Class Referenceabstract

An interface for intranode process management classes. More...

#include <be_process_manager.h>

Inherited by BiometricEvaluation::Process::ForkManager, and BiometricEvaluation::Process::POSIXThreadManager.

Public Member Functions

 Manager ()
 Manager constructor. More...
 
virtual std::shared_ptr< WorkerControlleraddWorker (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...
 

Protected Member Functions

virtual void _wait ()=0
 Do not return until all spawned processes exited. More...
 

Protected Attributes

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...
 

Detailed Description

An interface for intranode process management classes.

Definition at line 29 of file be_process_manager.h.

Constructor & Destructor Documentation

◆ Manager()

BiometricEvaluation::Process::Manager::Manager ( )

Manager constructor.

◆ ~Manager()

virtual BiometricEvaluation::Process::Manager::~Manager ( )
virtual

Manager destructor.

Member Function Documentation

◆ addWorker()

virtual std::shared_ptr< WorkerController > BiometricEvaluation::Process::Manager::addWorker ( std::shared_ptr< Worker worker)
pure virtual

Adds a Worker to be managed by this Manager.

Parameters
workerA Worker instance to run.
Returns
shared_ptr to worker.

Implemented in BiometricEvaluation::Process::ForkManager, and BiometricEvaluation::Process::POSIXThreadManager.

◆ getNumCompletedWorkers()

virtual uint32_t BiometricEvaluation::Process::Manager::getNumCompletedWorkers ( ) const
virtual

Obtain the number of Workers that have exited.

Returns
The number of Workers that have exited.
Exceptions
Error::StrategyErrorNo Workers have started working yet.

◆ getNumActiveWorkers()

virtual uint32_t BiometricEvaluation::Process::Manager::getNumActiveWorkers ( ) const
virtual

Obtain the number of Workers that are still working.

Returns
The number of Workers that are still working.
Exceptions
Error::StrategyErrorNo Workers have started working yet.

◆ getTotalWorkers()

virtual uint32_t BiometricEvaluation::Process::Manager::getTotalWorkers ( ) const
virtual

Obtain the number of Workers this class is handling.

Returns
Number of Workers.

◆ startWorkers()

virtual void BiometricEvaluation::Process::Manager::startWorkers ( bool  wait = true,
bool  communicate = false 
)
pure virtual

Begin Worker's work.

Parameters
[in]waitWhether or not to wait for all Workers to return before returning.
[in]communicateWhether or not to enable communication among the Workers and Managers.
Exceptions
Error::ObjectExistsAt least one Worker is already working.
Error::StrategyErrorProblem starting Workers.

Implemented in BiometricEvaluation::Process::ForkManager, and BiometricEvaluation::Process::POSIXThreadManager.

◆ startWorker()

virtual void BiometricEvaluation::Process::Manager::startWorker ( std::shared_ptr< WorkerController worker,
bool  wait = true,
bool  communicate = false 
)
pure virtual

Start a Worker.

Parameters
workerPointer to a WorkerController that is being managed by this Manager instance.
waitWhether or not to wait for this Worker to exit before returning control to the caller.
[in]communicateWhether or not to enable communication among the Workers and Managers.
Exceptions
Error::ObjectExistsworker is already working.
Error::StrategyErrorworker is not managed by this Manager instance.
Note
Some implementations of this interface may call the system exit function from this routine. Therefore, the application's implementation of workerMain() should release all resources before returning.

Implemented in BiometricEvaluation::Process::ForkManager, and BiometricEvaluation::Process::POSIXThreadManager.

◆ waitForWorkerExit()

virtual void BiometricEvaluation::Process::Manager::waitForWorkerExit ( )
pure 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.

Implemented in BiometricEvaluation::Process::ForkManager, and BiometricEvaluation::Process::POSIXThreadManager.

◆ reset()

virtual void BiometricEvaluation::Process::Manager::reset ( )
virtual

Reuse all Workers.

Exceptions
Error::ObjectExistsAt least one Worker is still working.

◆ stopWorker()

virtual void BiometricEvaluation::Process::Manager::stopWorker ( std::shared_ptr< WorkerController worker)
pure virtual

Ask Worker to return as soon as possible.

Parameters
workerPointer to the WorkerController that should be stopped.
Exceptions
Error::ObjectDoesNotExistworker is not working.
Error::StrategyErrorProblem asking worker to stop.

Implemented in BiometricEvaluation::Process::ForkManager, and BiometricEvaluation::Process::POSIXThreadManager.

◆ waitForMessage()

virtual bool BiometricEvaluation::Process::Manager::waitForMessage ( std::shared_ptr< WorkerController > &  sender,
int *  nextFD = nullptr,
int  numSeconds = -1 
) const
virtual

Wait for a message from a Worker.

Parameters
[out]senderReference to a shared pointer of the WorkerController that sent the message.
[in,out]nextFDLocation to store a pipe that has data to read.
[in]numSecondsNumber of seconds to wait for a message, or < 0 to block.
Returns
true if there is a Worker sending a message false otherwise or if an error occurred.

◆ getNextMessage()

virtual bool BiometricEvaluation::Process::Manager::getNextMessage ( std::shared_ptr< WorkerController > &  sender,
Memory::uint8Array message,
int  numSeconds = -1 
) const
virtual

Obtain a message from a Worker.

Parameters
[out]senderReference to a shared pointer of the WorkerController that sent the message.
[out]messageReference to a buffer to hold the message.
[in]numSecondsNumber of seconds to wait for a message, or < 0 to block.
Returns
true if there is a message, false otherwise.
Exceptions
Error::ObjectDoesNotExist(Unexpected) widowed pipe.
Error::StrategyErrorError receiving message.

◆ broadcastMessage()

virtual void BiometricEvaluation::Process::Manager::broadcastMessage ( Memory::uint8Array message) const
virtual

Send one message to all Workers.

Parameters
messageThe message to send to all Workers.
Exceptions
Error::StrategyErrorError propagated from the WorkerController.

◆ _wait()

virtual void BiometricEvaluation::Process::Manager::_wait ( )
protectedpure virtual

Do not return until all spawned processes exited.

Member Data Documentation

◆ _workers

std::vector<std::shared_ptr<WorkerController> > BiometricEvaluation::Process::Manager::_workers
protected

Workers that have been added.

Definition at line 261 of file be_process_manager.h.

◆ _pendingExit

std::vector<std::shared_ptr<WorkerController> > BiometricEvaluation::Process::Manager::_pendingExit
protected

Workers that are about to exit (stop requested).

Definition at line 265 of file be_process_manager.h.


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