libkipr  1.0.0
thread.hpp
Go to the documentation of this file.
1 #ifndef _KIPR_THREAD_THREAD_HPP_
2 #define _KIPR_THREAD_THREAD_HPP_
3 
4 #ifndef WIN32
5 #include <pthread.h>
6 #else
7 #define WIN32_LEAN_AND_MEAN
8 #define NOMINMAX
9 #include <windows.h>
10 #endif
11 
12 #include "kipr/export/export.h"
13 
14 namespace kipr
15 {
16  namespace thread
17  {
19  {
20  public:
21  Mutex();
22  ~Mutex();
23 
24  void lock();
25  bool tryLock();
26 
27  void unlock();
28 
29  private:
30  Mutex(const Mutex &rhs);
31 
32  #ifdef WIN32
33  CRITICAL_SECTION m_handle;
34  #else
35  pthread_mutex_t m_handle;
36  #endif
37  };
38 
40  {
41  public:
42  Thread();
43  virtual ~Thread();
44 
45  void start();
46  void join();
47 
48  virtual void run() = 0;
49 
50  private:
51  #ifndef WIN32
52  pthread_t m_thread;
53  #else
54  HANDLE m_thread;
55  #endif
56  };
57  }
58 }
59 
60 #endif
Definition: thread.hpp:19
Definition: thread.hpp:40
virtual void run()=0
#define EXPORT_SYM
Definition: export.h:7
Definition: accel.hpp:7
A thread, or separate process.
Definition: thread.h:38