00001 /* 00002 * $Id: Thread.h 562 2007-12-02 08:04:16Z mindstorm2600 $ 00003 * 00004 * X-VR2 00005 * 00006 * Copyright (C) Juan V. Guerrero 2007 00007 * 00008 * Juan V. Guerrero <mindstorm2600@users.sourceforge.net> 00009 * 00010 * This program is free software, distributed under the terms of 00011 * the GNU General Public License Version 2. See the LICENSE file 00012 * at the top of the source tree. 00013 */ 00014 #ifndef __XVR2_THREAD_H__ 00015 #define __XVR2_THREAD_H__ 00016 00017 #include<xvr2/Object.h> 00018 #ifdef USE_POSIX_THREADS 00019 #include<pthread.h> 00020 #else 00021 #include<pth.h> 00022 #endif 00023 00024 #include<xvr2/Mutex.h> 00025 #include<xvr2/SharedVar.h> 00026 #include<xvr2/CoreExceptions.h> 00027 #include<xvr2/ThreadFinalizator.h> 00028 #include<xvr2/Threading.h> 00029 00030 namespace xvr2{ 00031 00032 class Thread:public ThreadFinalizator{ 00033 private: 00034 protected: 00036 Thread(); 00037 bool _detached; 00038 public: 00041 SharedVar<bool> _started; 00044 SharedVar<bool> _terminated; 00047 virtual ~Thread(); 00052 virtual void start(); 00053 virtual void start(Threading::SchedPolicy pol); 00061 virtual void run() = 0; 00062 virtual void operator()(){ } 00066 bool isRunning(); 00067 00070 void setPriority(int prio); 00073 UInt64 numericID(); 00074 UInt64 numericID() const ; 00075 const bool started(); 00076 const bool terminated(); 00077 const bool running(); 00078 const bool joinable(); 00079 00080 void join(); 00081 }; 00082 00083 } 00084 00085 #endif