00001 //--------------------------------------------------------------- 00002 // Go4 Release Package v2.10-5 (build 21005) 00003 // 03-Nov-2005 00004 //--------------------------------------------------------------- 00005 // The GSI Online Offline Object Oriented (Go4) Project 00006 // Experiment Data Processing at DVEE 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 #include "TCondition.h" 00021 #include "TThread.h" 00022 00023 class TGo4Runnable; 00024 00036 class TGo4Thread : public TNamed { 00037 00038 public: 00039 00040 TGo4Thread(const TGo4Thread &right); 00041 00049 TGo4Thread (const char* name, TGo4Runnable* runnable, Bool_t internal = kTRUE ); 00050 00051 virtual ~TGo4Thread(); 00052 00053 TGo4Thread & operator=(const TGo4Thread &right); 00054 00058 Bool_t Create (); 00059 00063 Bool_t Cancel (); 00064 00070 Bool_t ReCreate (); 00071 00076 Bool_t Start (); 00077 00081 Bool_t Stop (); 00082 00088 static void Sleep (UInt_t millisecs); 00089 00093 Int_t GetPID () const 00094 { 00095 return fiThreadPID; 00096 } 00097 00101 Int_t GetSelfID () const 00102 { 00103 return fiThreadSelfID; 00104 } 00105 00110 Bool_t IsInternal () const 00111 { 00112 return fbIsInternal; 00113 } 00114 00119 Bool_t IsCreated () const 00120 { 00121 return fbIsCreated; 00122 } 00123 00127 Bool_t IsRunning () const 00128 { 00129 return fbIsRunning; 00130 } 00131 00135 Bool_t IsWaiting () 00136 { 00137 return fbIsWaiting; 00138 } 00139 00140 private: 00141 00151 static void Threadfunc (void* arg); 00152 00156 TGo4Runnable* GetRunnable() 00157 { 00158 return fxRunnable; 00159 } 00160 00161 TCondition* GetCondition() 00162 { 00163 return fxCondition; 00164 } 00165 00166 void SetPID() 00167 { 00168 fiThreadPID=gSystem->GetPid(); 00169 } 00170 00171 void SetSelfID() 00172 { 00173 fiThreadSelfID=TThread::SelfId(); 00174 } 00175 00176 void SetWaiting(Bool_t mode=kTRUE) 00177 { 00178 fbIsWaiting=mode; 00179 } 00180 00188 Bool_t fbIsInternal; 00189 00194 Bool_t fbIsCreated; 00195 00199 Bool_t fbIsRunning; 00200 00204 Int_t fiThreadPID; 00205 00209 Int_t fiThreadSelfID; 00210 00214 Bool_t fbIsWaiting; 00215 00225 TGo4Runnable *fxRunnable; 00226 00227 TThread *fxThread; 00228 00229 TCondition *fxCondition; 00230 00231 private: 00232 TGo4Thread(); 00233 }; 00234 00235 #endif 00236 00237 //----------------------------END OF GO4 SOURCE FILE ---------------------