]> git.tdb.fi Git - libs/core.git/blob - source/core/thread.h
Drop copyright and license notices from source files
[libs/core.git] / source / core / thread.h
1 #ifndef MSP_CORE_THREAD_H_
2 #define MSP_CORE_THREAD_H_
3
4 namespace Msp {
5
6 /**
7 Base class for threads.  To create a thread for some task, derive it from this
8 class and implement the main() function.  Note that threads are not
9 automatically started upon creation - you must manually call launch() instead.
10 This is to allow initializing variables of the derived class before the thread
11 is started.
12 */
13 class Thread
14 {
15 private:
16         struct Private;
17
18         Private *priv_;
19         bool launched_;
20
21 protected:
22         Thread();
23 private:
24         Thread(const Thread &);
25         Thread &operator=(const Thread &);
26 public:
27         virtual ~Thread();
28
29         void join();
30         void kill();
31 protected:
32         void launch();
33         virtual void main() = 0;
34 };
35
36 } // namespace Msp
37
38 #endif