2 This file is part of libmspframework
3 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
4 Distributed under the LGPL
6 #ifndef MSP_FRAMEWORK_THREAD_H_
7 #define MSP_FRAMEWORK_THREAD_H_
14 Base class for threads. To create a thread for some task, derive it from this
15 class and implement the main() function. Note that threads are not
16 automatically started upon creation - you must manually call launch() instead.
17 This is to allow initializing variables of the derived class before the thread
28 Thread(): launched_(false) { }
30 virtual void main()=0;
36 Thread(const Thread &);
37 Thread &operator=(const Thread &);
40 # define THREAD_RETURN_ DWORD WINAPI
42 # define THREAD_RETURN_ void *
44 static THREAD_RETURN_ main_(void *t) { ((Thread *)t)->main(); return 0; }