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