version 0.1.3
[fms.git] / include / pthreadwrapper / thread.h
diff --git a/include/pthreadwrapper/thread.h b/include/pthreadwrapper/thread.h
new file mode 100644 (file)
index 0000000..18e731e
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef _pthread_thread_\r
+#define _pthread_thread_\r
+\r
+#include "noncopyable.h"\r
+#include "runnable.h"\r
+#include <pthread.h>\r
+\r
+namespace PThread\r
+{\r
+\r
+class Runnable;\r
+\r
+class Thread:public NonCopyable\r
+{\r
+public:\r
+       Thread();\r
+       Thread(Runnable *runnable);\r
+       ~Thread();\r
+\r
+       void Join();\r
+       void Cancel();\r
+\r
+       void Sleep(const long ms);\r
+       const bool IsCancelled()        { return m_cancelled; }\r
+       const bool IsRunning()          { return m_running; }\r
+\r
+private:\r
+       void Start();\r
+       static void *EntryPoint(void *pthis);\r
+\r
+       pthread_t m_thread;\r
+       bool m_running;                         // thread (object) is currently running\r
+       bool m_cancelled;\r
+       Runnable *m_runnable;           // actual object that is being run\r
+\r
+};\r
+\r
+}      // namespace\r
+\r
+#endif // _pthread_thread_\r