00001 /* 00002 ######################################################################### 00003 # 00004 # This file is part of trustyRC. 00005 # 00006 # trustyRC, fully modular IRC robot 00007 # Copyright (C) 2006-2008 Nicoleau Fabien 00008 # 00009 # trustyRC is free software: you can redistribute it and/or modify 00010 # it under the terms of the GNU General Public License as published by 00011 # the Free Software Foundation, either version 3 of the License, or 00012 # (at your option) any later version. 00013 # 00014 # trustyRC 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 00017 # GNU General Public License for more details. 00018 # 00019 # You should have received a copy of the GNU General Public License 00020 # along with trustyRC. If not, see <http://www.gnu.org/licenses/>. 00021 # 00022 ######################################################################### 00023 */ 00024 00029 #ifndef CPPTHREAD_H 00030 #define CPPTHREAD_H 00031 00032 #include <pthread.h> 00033 00034 typedef void* (*threadProcess)(void*); 00036 typedef struct { 00037 threadProcess process; 00038 void* args; 00039 bool running; 00040 bool finished; 00041 } threadInfos; 00042 00048 class CPPThread 00049 { 00050 private: 00052 pthread_t* handle; 00054 static void* threadStartup(void*); 00056 threadInfos ti; 00057 public: 00059 CPPThread(); 00061 ~CPPThread(); 00063 bool exec(threadProcess,void*); 00065 bool terminate(); 00067 bool isRunning(); 00069 bool isFinished(); 00071 void* join(); 00073 pthread_t* getHandle(); 00074 }; 00075 00076 #endif