/* ******************************************************************* * * * Class Name: Thread * * Author: Arash Partow * * * ******************************************************************* */ #ifndef INCLUDE_POSIXTHREAD_H #define INCLUDE_POSIXTHREAD_H #define THREAD_IDLE 0 #define THREAD_RUNNING 1 #define THREAD_DEAD 2 #define THREAD_GCR 3 #include #include #include #include #include #include #include "StringTokenizer.h" #include #include class Thread { public: Thread(); virtual ~Thread(); bool operator == (const Thread& obj) const; int start(); bool setThreadState(int state); int getThreadState(); void terminate(); void exit(); protected: virtual void execute()=0; static void* threadFunction(void *); void run(); void detach(void) const; void yield(void) const; int self() const; int join(void); private: pthread_attr_t attr; pthread_t threadID; int currentState; }; #endif