X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fthread.h;h=92923f31bbd5718eb8816aed1e28d9e8e72dadda;hb=b56eb5ec1da675da0c66abc53c1e4f6c4e4cccbd;hp=937d161938b20aad593653bbe99ed882aeb77156;hpb=fe77fc6b869a71bf94d501a0762579f4ddbc5094;p=libs%2Fcore.git diff --git a/source/core/thread.h b/source/core/thread.h index 937d161..92923f3 100644 --- a/source/core/thread.h +++ b/source/core/thread.h @@ -1,10 +1,12 @@ -/* +/* $Id$ + This file is part of libmspcore Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#ifndef MSP_FRAMEWORK_THREAD_H_ -#define MSP_FRAMEWORK_THREAD_H_ + +#ifndef MSP_CORE_THREAD_H_ +#define MSP_CORE_THREAD_H_ #include "types.h" @@ -19,30 +21,34 @@ is started. */ class Thread { +private: + ThreadHandle thread_; + bool launched_; + +protected: + Thread(): launched_(false) { } public: + virtual ~Thread(); + void join(); void cancel(); void kill(); - virtual ~Thread(); protected: - Thread(): launched_(false) { } void launch(); - virtual void main()=0; + virtual void main() = 0; void check_cancel(); -private: - ThreadHandle thread_; - bool launched_; - - Thread(const Thread &); - Thread &operator=(const Thread &); +private: + static #ifdef WIN32 -# define THREAD_RETURN_ DWORD WINAPI + DWORD WINAPI #else -# define THREAD_RETURN_ void * + void * #endif - static THREAD_RETURN_ main_(void *t) { ((Thread *)t)->main(); return 0; } -#undef THREAD_RETURN_ + main_(void *t) { (reinterpret_cast(t))->main(); return 0; } + + Thread(const Thread &); + Thread &operator=(const Thread &); }; } // namespace Msp