X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fthread.h;fp=source%2Fthread.h;h=a115853211ba122ddb3628326339d43473474a0b;hb=1013e3c216cdf8e0ecc0f3b1e8314989b5333818;hp=0000000000000000000000000000000000000000;hpb=5780f0826f057f99593de46a583be7c098efaf90;p=libs%2Fcore.git diff --git a/source/thread.h b/source/thread.h new file mode 100644 index 0000000..a115853 --- /dev/null +++ b/source/thread.h @@ -0,0 +1,35 @@ +/* +This file is part of libmspframework +Copyright © 2006 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ +#ifndef MSP_FRAMEWORK_THREAD_H_ +#define MSP_FRAMEWORK_THREAD_H_ + +#include + +namespace Msp { + +class Thread +{ +public: + void *join(); + void kill(int s) { pthread_kill(thread_, s); } + virtual ~Thread(); +protected: + Thread() { } + void launch() { pthread_create(&thread_, 0, &main_, this); } + virtual void *main()=0; + void exit(void *r) { pthread_exit(r); } +private: + pthread_t thread_; + + Thread(const Thread &); + Thread &operator=(const Thread &); + + static void *main_(void *t) { return ((Thread *)t)->main(); } +}; + +} // namespace Msp + +#endif