libkovan  1
The kovan standard library
thread.hpp
Go to the documentation of this file.
1 #ifndef _THREAD_HPP_
2 #define _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 "export.h"
13 
15 {
16 public:
17  Mutex();
18  ~Mutex();
19 
20  void lock();
21  bool tryLock();
22 
23  void unlock();
24 
25 private:
26  Mutex(const Mutex &rhs);
27 
28 #ifdef WIN32
29  CRITICAL_SECTION m_handle;
30 #else
31  pthread_mutex_t m_handle;
32 #endif
33 };
34 
36 {
37 public:
38  Thread();
39  virtual ~Thread();
40 
41  void start();
42  void join();
43 
44  virtual void run() = 0;
45 
46 private:
47 #ifndef WIN32
48  pthread_t m_thread;
49 #else
50  HANDLE m_thread;
51 #endif
52 };
53 
54 #endif
Definition: thread.hpp:14
Definition: thread.hpp:35
#define EXPORT_SYM
Definition: export.h:7