00001 #ifndef WIBBLE_SYS_THREAD_H
00002 #define WIBBLE_SYS_THREAD_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <wibble/sys/macros.h>
00025 #include <wibble/exception.h>
00026 #ifdef POSIX
00027 #include <pthread.h>
00028 #endif
00029
00030 #ifdef _WIN32
00031 #include <windows.h>
00032 #include <process.h>
00033 #endif
00034 #include <signal.h>
00035
00036 namespace wibble {
00037 namespace sys {
00038
00076 class Thread
00077 {
00078 protected:
00079 #ifdef POSIX
00080 pthread_t thread;
00081 #endif
00082
00083 #ifdef _WIN32
00084 unsigned int thread;
00085 HANDLE hThread;
00086 #endif
00087
00092 virtual const char* threadTag() { return "generic"; }
00093
00098 virtual void* main() = 0;
00099
00101 #ifdef POSIX
00102 static void* Starter(void* parm);
00103 #endif
00104
00105 #ifdef _WIN32
00106 static unsigned __stdcall Starter(void* parm);
00107 #endif
00108
00109 void testcancel();
00110
00111 public:
00112 virtual ~Thread() {}
00113
00115 void start();
00116
00118 void startDetached();
00119
00121 void* join();
00122
00124 void detach();
00125
00127 void cancel();
00128
00130 void kill(int signal);
00131 };
00132
00133 }
00134 }
00135
00136
00137 #endif