X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=include%2Fpthreadwrapper%2Fthread.h;fp=include%2Fpthreadwrapper%2Fthread.h;h=18e731e0bbe768c0891d1d224b465d861b9e4366;hb=c7fcb4c4bc5012a584add81a9509fc1f84c3c688;hp=0000000000000000000000000000000000000000;hpb=964f55fd550fc711c0320ce6a24ad713040695d0;p=fms.git diff --git a/include/pthreadwrapper/thread.h b/include/pthreadwrapper/thread.h new file mode 100644 index 0000000..18e731e --- /dev/null +++ b/include/pthreadwrapper/thread.h @@ -0,0 +1,40 @@ +#ifndef _pthread_thread_ +#define _pthread_thread_ + +#include "noncopyable.h" +#include "runnable.h" +#include + +namespace PThread +{ + +class Runnable; + +class Thread:public NonCopyable +{ +public: + Thread(); + Thread(Runnable *runnable); + ~Thread(); + + void Join(); + void Cancel(); + + void Sleep(const long ms); + const bool IsCancelled() { return m_cancelled; } + const bool IsRunning() { return m_running; } + +private: + void Start(); + static void *EntryPoint(void *pthis); + + pthread_t m_thread; + bool m_running; // thread (object) is currently running + bool m_cancelled; + Runnable *m_runnable; // actual object that is being run + +}; + +} // namespace + +#endif // _pthread_thread_