OpenPose 1.0.0rc2 OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
worker.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_THREAD_WORKER_HPP
2 #define OPENPOSE_THREAD_WORKER_HPP
3
4 #include <openpose/core/common.hpp>
5
6 namespace op
7 {
8 template<typename TDatums>
9 class Worker
10 {
11 public:
12 Worker();
13
14 virtual ~Worker();
15
16 virtual void initializationOnThread() = 0;
17
18 bool checkAndWork(TDatums& tDatums);
19
20 inline bool isRunning() const
21 {
22 return mIsRunning;
23 }
24
25 inline void stop()
26 {
27 mIsRunning = false;
28 }
29
30 // Virtual in case some function needs spetial stopping (e.g., buffers might not stop inmediately and need a
31 // few iterations)
32 inline virtual void tryStop()
33 {
34 stop();
35 }
36
37 protected:
38 virtual void work(TDatums& tDatums) = 0;
39
40 private:
41 bool mIsRunning;
42
43 DELETE_COPY(Worker);
44 };
45 }
46
47
48
49
50
51 // Implementation
52 namespace op
53 {
54 template<typename TDatums>
55 Worker<TDatums>::Worker() :
56 mIsRunning{true}
57 {
58 }
59
60 template<typename TDatums>
61 Worker<TDatums>::~Worker()
62 {
63 }
64
65 template<typename TDatums>
66 bool Worker<TDatums>::checkAndWork(TDatums& tDatums)
67 {
68 if (mIsRunning)
69 work(tDatums);
70 return mIsRunning;
71 }
72
73 COMPILE_TEMPLATE_DATUM(Worker);
74 }
75
76 #endif // OPENPOSE_THREAD_WORKER_HPP
op::Worker
Definition: worker.hpp:9
op::Worker::~Worker
virtual ~Worker()
Definition: worker.hpp:61
common.hpp
op::Worker::Worker
Worker()
Definition: worker.hpp:55
op::Worker::tryStop
virtual void tryStop()
Definition: worker.hpp:32
op::Worker::isRunning
bool isRunning() const
Definition: worker.hpp:20
op::Worker::initializationOnThread
virtual void initializationOnThread()=0
op::Worker::work
virtual void work(TDatums &tDatums)=0
op::COMPILE_TEMPLATE_DATUM
COMPILE_TEMPLATE_DATUM(WPoseTriangulation)
op::Worker::checkAndWork
bool checkAndWork(TDatums &tDatums)
Definition: worker.hpp:66
op::Worker::stop
void stop()
Definition: worker.hpp:25