1 | #ifndef THREAD_LOOPING_HPP_ |
2 | #define THREAD_LOOPING_HPP_ |
3 |
|
4 |
|
5 | #include <thread> |
6 | #include <atomic> |
7 | #include <string> |
8 |
|
9 | #include "IThread.hpp" |
10 |
|
11 |
|
12 | class IUpdateable; |
13 |
|
14 |
|
15 | class ThreadLooping : IThread |
16 | { |
17 | public: |
18 | ThreadLooping(std::string thread_name, IUpdateable& thread_update); |
19 | ~ThreadLooping(); |
20 |
|
21 | void Start() override; |
22 | void Terminate() override; |
23 |
|
24 | bool IsRunning() override; |
25 | void WaitUntilFinished() override; |
26 |
|
27 | protected: |
28 | void ThreadRunLoop(); |
29 |
|
30 | IUpdateable& m_rThreadUpdate; |
31 | std::string m_threadName; |
32 | std::thread m_thread; |
33 | std::atomic<bool> m_aShouldThreadTerminate; |
34 | std::atomic<bool> m_aIsThreadRunning; |
35 | }; |
36 |
|
37 |
|
38 | #endif /* THREAD_LOOPING_HPP_ */ |
39 |
|