• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

thread.h

Go to the documentation of this file.
00001 #ifndef WIBBLE_SYS_THREAD_H
00002 #define WIBBLE_SYS_THREAD_H
00003 
00004 /*
00005  * OO encapsulation of Posix threads
00006  *
00007  * Copyright (C) 2003--2008  Enrico Zini <enrico@debian.org>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
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 // vim:set ts=4 sw=4:
00137 #endif

Generated on Tue May 10 2011 16:51:50 for wibble by  doxygen 1.7.1