Bites
A small library of miscellaneous C++ codes.
 All Classes Namespaces Functions Friends Pages
Thread.hpp
1 #ifndef BITES_THREAD_HPP_INCLUDED
2 #define BITES_THREAD_HPP_INCLUDED
3 
4 #include <thread>
5 
6 namespace bites {
7 
49 class Thread {
50 
51 public:
56  {
57  if (m_thread)
58  {
59  delete m_thread;
60  }
61  }
62 
66  void start ()
67  {
68  m_thread = new std::thread(&Thread::run, this);
69  }
70 
74  void join ()
75  {
76  if (m_thread)
77  {
78  m_thread->join();
79  }
80  }
81 
82 private:
83  std::thread* m_thread = NULL;
84 
88  virtual void run() = 0;
89 };
90 
91 } // namespace bites.
92 
93 #endif // BITES_THREAD_HPP_INCLUDED
Definition: Thread.hpp:49
void join()
Definition: Thread.hpp:74
void start()
Definition: Thread.hpp:66
~Thread()
Definition: Thread.hpp:55