![]() |
![]() |
00001 #ifndef UTILITIES_THREADS_THREAD_H 00002 #define UTILITIES_THREADS_THREAD_H 00003 // 00004 // V 0.0 00005 // 00006 #include <boost/thread/thread.hpp> 00007 #include <ostream> 00008 00011 class Thread { 00012 public: 00013 00015 static unsigned int self_tid(); 00016 00018 struct Terminate {}; 00019 00020 00021 unsigned int tid() const { return tid_;} 00022 00023 private: 00024 boost::thread * t1; 00025 unsigned int tid_; 00026 00027 public: 00028 00030 static void verboseOn(); 00031 00033 static void verboseOff(); 00034 00035 private: 00036 00037 static bool verbose; 00038 00040 void operator()(); 00041 struct Me { 00042 Me(Thread & im) : me(im){} 00043 void operator()() {me();} 00044 Thread & me; 00045 }; 00046 friend struct Me; 00047 00048 public: 00049 00051 std::ostream cout; 00052 00054 Thread(); 00055 00057 virtual ~Thread(); 00058 protected: 00059 void initialize(); 00060 void finalize(); 00061 00062 private: 00063 00065 virtual void run()=0; 00066 00068 virtual void terminate()=0; 00069 00071 virtual void abort()=0; 00072 00073 }; 00074 00075 #endif // UTILITIES_THREADS_THREAD_H