libkovan  1
The kovan standard library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #endif
7 
8 #include "export.h"
9 
11 {
12 public:
13  Mutex();
14  ~Mutex();
15 
16  void lock();
17  bool tryLock();
18 
19  void unlock();
20 
21 private:
22  Mutex(const Mutex &rhs);
23 
24 #ifdef WIN32
25  CRITICAL_SECTION m_handle;
26 #else
27  pthread_mutex_t m_handle;
28 #endif
29 };
30 
32 {
33 public:
34  Thread();
35  virtual ~Thread();
36 
37  void start();
38  void join();
39 
40  virtual void run() = 0;
41 
42 private:
43 #ifndef WIN32
44  pthread_t m_thread;
45 #else
46  unsigned long m_thread;
47 #endif
48 };
49 
50 #endif