00001 //------------------------------------------------------------- 00002 // Go4 Release Package v3.04-01 (build 30401) 00003 // 28-November-2008 00004 //--------------------------------------------------------------- 00005 // The GSI Online Offline Object Oriented (Go4) Project 00006 // Experiment Data Processing at EE department, GSI 00007 //--------------------------------------------------------------- 00008 // 00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI 00010 // Planckstr. 1, 64291 Darmstadt, Germany 00011 //Contact: http://go4.gsi.de 00012 //---------------------------------------------------------------- 00013 //This software can be used under the license agreements as stated 00014 //in Go4License.txt file which is part of the distribution. 00015 //---------------------------------------------------------------- 00016 #ifndef TGo4Thread_H 00017 #define TGo4Thread_H 00018 00019 #include "TNamed.h" 00020 00021 class TThread; 00022 class TCondition; 00023 class TGo4Runnable; 00024 00035 class TGo4Thread : public TNamed { 00036 00037 public: 00038 00039 TGo4Thread(const TGo4Thread &right); 00040 00046 TGo4Thread (const char* name, TGo4Runnable* runnable, Bool_t internal = kTRUE); 00047 00048 virtual ~TGo4Thread(); 00049 00051 Bool_t Create(); 00052 00054 Bool_t Cancel(); 00055 00059 Bool_t ReCreate(); 00060 00063 Bool_t Start(); 00064 00066 Bool_t Stop(); 00067 00070 static void Sleep(UInt_t millisecs); 00071 00073 Int_t GetPID() const { return fiThreadPID; } 00074 00076 Long_t GetSelfID() const { return fiThreadSelfID; } 00077 00080 Bool_t IsInternal() const { return fbIsInternal; } 00081 00083 Bool_t IsCreated() const { return fbIsCreated; } 00084 00086 Bool_t IsRunning() const { return fbIsRunning; } 00087 00089 Bool_t IsWaiting() const { return fbIsWaiting; } 00090 00091 private: 00092 00097 static void Threadfunc (void* arg); 00098 00100 TGo4Runnable* GetRunnable() const { return fxRunnable; } 00101 00102 TCondition* GetCondition() const { return fxCondition; } 00103 00104 void SetPID(); 00105 00106 void SetSelfID(); 00107 00108 void SetWaiting(Bool_t mode=kTRUE) { fbIsWaiting=mode; } 00109 00115 Bool_t fbIsInternal; 00116 00118 Bool_t fbIsCreated; 00119 00121 Bool_t fbIsRunning; 00122 00124 Int_t fiThreadPID; 00125 00127 Long_t fiThreadSelfID; 00128 00130 Bool_t fbIsWaiting; 00131 00139 TGo4Runnable *fxRunnable; 00140 00141 TThread *fxThread; 00142 00143 TCondition *fxCondition; 00144 00145 private: 00146 TGo4Thread(); 00147 }; 00148 00149 #endif 00150 00151 //----------------------------END OF GO4 SOURCE FILE ---------------------