NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_process_posixthreadmanager.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef __BE_PROCESS_POSIXTHREADMANAGER_H__
12#define __BE_PROCESS_POSIXTHREADMANAGER_H__
13
14#include <pthread.h>
15
16#include <be_process_manager.h>
18
19namespace BiometricEvaluation
20{
21 namespace Process
22 {
23 /* Forward declaration */
24 class POSIXThreadWorkerController;
25
32 {
33 public:
38
49 std::shared_ptr<WorkerController>
51 std::shared_ptr<Worker> worker);
52
69 void
71 bool wait = true,
72 bool communicate = false);
73
93 void
95 std::shared_ptr<WorkerController> worker,
96 bool wait = true,
97 bool communicate = false);
98
112 void
114 std::shared_ptr<WorkerController> workerController);
115
116 void
118
124
125 private:
130 void
131 _wait();
132 };
133
139 {
140 public:
149 void
151
159 bool
161 const;
162
163 bool
165 const;
166
172
173 protected:
174
175 private:
184 std::shared_ptr<Worker> worker);
185
203 void
204 start(
205 bool communicate = false);
206
216 void
217 stop();
218
230 static void *
231 workerMainWrapper(
232 void *_this);
233
234 /*
235 * Friends.
236 * XXX We just need addWorker(), startWorkers(), and
237 * XXX _wait() to be friended, but you cannot friend
238 * XXX a private function (_wait()).
239 * TODO Eliminate _wait() from WorkerController?
240 */
241 friend class POSIXThreadManager;
242
244 pthread_t _thread;
245
247 bool _working;
248
250 bool _hasWorked;
251 };
252 }
253}
254
255#endif /* __BE_PROCESS_POSIXTHREADMANAGER_H__ */
An interface for intranode process management classes.
Manager implementation that starts Workers in POSIX threads.
std::shared_ptr< WorkerController > addWorker(std::shared_ptr< Worker > worker)
Adds a Worker to be managed by this Manager.
void startWorker(std::shared_ptr< WorkerController > worker, bool wait=true, bool communicate=false)
Start a Worker.
void startWorkers(bool wait=true, bool communicate=false)
Begin Worker's work.
void waitForWorkerExit()
Block until all Workers have exited.
void stopWorker(std::shared_ptr< WorkerController > workerController)
Ask Worker to exit.
~POSIXThreadManager()
~POSIXThreadManager destructor.
POSIXThreadManager()
POSIXThreadManager constructor.
Decorated Worker returned from a Process::POSIXThreadManager.
bool everWorked() const
Obtain whether or not this Worker has ever worked.
bool isWorking() const
Obtain whether or not Worker is working.
~POSIXThreadWorkerController()
POSIXThreadWorkerController destructor.
Wrapper of a Worker returned from a Process::Manager.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...