xoreos  0.0.5
thread.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
27 #ifndef COMMON_THREAD_H
28 #define COMMON_THREAD_H
29 
30 #include "src/common/atomic.h"
31 
32 #include "src/common/fallthrough.h"
34 #include <SDL_thread.h>
36 
37 #include <boost/noncopyable.hpp>
38 
39 #include "src/common/ustring.h"
40 
41 namespace Common {
42 
44 class Thread : boost::noncopyable {
45 public:
46  Thread();
47  virtual ~Thread();
48 
49  bool createThread(const UString &name = "");
50  bool destroyThread();
51 
52 protected:
53  boost::atomic<bool> _killThread;
54 
55 private:
56  SDL_Thread *_thread;
58 
59  boost::atomic<bool> _threadRunning;
60 
61  virtual void threadMethod() = 0;
62 
63  static int threadHelper(void *obj);
64 };
65 
66 } // End of namespace Common
67 
68 #endif // COMMON_THREAD_H
Definition: 2dafile.h:39
#define START_IGNORE_IMPLICIT_FALLTHROUGH
Definition: fallthrough.h:79
SDL_Thread * _thread
Definition: thread.h:56
A class holding an UTF-8 string.
Definition: ustring.h:48
bool destroyThread()
Definition: thread.cpp:64
boost::atomic< bool > _killThread
Definition: thread.h:53
virtual ~Thread()
Definition: thread.cpp:40
bool createThread(const UString &name="")
Definition: thread.cpp:44
A class that creates its own thread.
Definition: thread.h:44
Helper header to include boost::atomic.
#define STOP_IGNORE_IMPLICIT_FALLTHROUGH
Definition: fallthrough.h:80
Unicode string handling.
virtual void threadMethod()=0
static int threadHelper(void *obj)
Definition: thread.cpp:106
Compiler-specific defines to mark an implicit switch-case fallthrough.
Common::UString _name
Definition: thread.h:57
boost::atomic< bool > _threadRunning
Definition: thread.h:59