Wyatt  1.0.1
Thread.h
1 /*
2  thread.h
3 
4  Header for a Java style thread class in C++.
5 
6  ------------------------------------------
7 
8  Copyright (c) 2013 Vic Hargrave
9 
10  Licensed under the Apache License, Version 2.0 (the "License");
11  you may not use this file except in compliance with the License.
12  You may obtain a copy of the License at
13 
14  http://www.apache.org/licenses/LICENSE-2.0
15 
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 */
22 
23 #ifndef __thread_h__
24 #define __thread_h__
25 
26 #include <pthread.h>
27 #include <atomic>
28 
32 class Thread
33 {
34  public:
35  Thread();
36  virtual ~Thread();
37 
38  int start();
39  int join();
40  int detach();
41  void signal(int signal);
42  pthread_t self();
43 
44  virtual void* run() = 0;
45  protected:
46  std::atomic<int> m_signal;
47  private:
48  pthread_t m_tid;
49  int m_running;
50  int m_detached;
51 };
52 
53 #endif
Definition: Thread.h:32