1 #ifndef MSP_CORE_THREAD_H_
2 #define MSP_CORE_THREAD_H_
9 Base class for threads. To create a thread for some task, derive it from this
10 class and implement the main() function. Note that threads are not
11 automatically started upon creation - you must manually call launch() instead.
12 This is to allow initializing variables of the derived class before the thread
34 Thread(const std::string & = std::string());
36 Thread(const Thread &);
37 Thread &operator=(const Thread &);
41 const std::string &get_name() const { return name_; }
43 /** Indicates whether the thread has finished running. */
44 bool is_finished() { return state_>=FINISHED; }
46 /** Waits for the thread to exit. Calling this from the thread will cause a
50 /** Violently terminates the thread. This should only be used as a last
51 resort, as the thread gets no chance to clean up. */
55 /** Starts the thread. Can only be called once for each Thread instance. */
61 void platform_launch();
62 void platform_setname();
65 virtual void main() = 0;