00001 // $Id: TGo4Thread.h 478 2009-10-29 12:26:09Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #ifndef TGo4Thread_H 00015 #define TGo4Thread_H 00016 00017 #include "TNamed.h" 00018 00019 class TThread; 00020 class TCondition; 00021 class TGo4Runnable; 00022 00033 class TGo4Thread : public TNamed { 00034 00035 public: 00036 00037 TGo4Thread(const TGo4Thread &right); 00038 00044 TGo4Thread (const char* name, TGo4Runnable* runnable, Bool_t internal = kTRUE); 00045 00046 virtual ~TGo4Thread(); 00047 00049 Bool_t Create(); 00050 00052 Bool_t Cancel(); 00053 00057 Bool_t ReCreate(); 00058 00061 Bool_t Start(); 00062 00064 Bool_t Stop(); 00065 00068 static void Sleep(UInt_t millisecs); 00069 00071 Int_t GetPID() const { return fiThreadPID; } 00072 00074 Long_t GetSelfID() const { return fiThreadSelfID; } 00075 00078 Bool_t IsInternal() const { return fbIsInternal; } 00079 00081 Bool_t IsCreated() const { return fbIsCreated; } 00082 00084 Bool_t IsRunning() const { return fbIsRunning; } 00085 00087 Bool_t IsWaiting() const { return fbIsWaiting; } 00088 00089 private: 00090 00095 static void Threadfunc (void* arg); 00096 00098 TGo4Runnable* GetRunnable() const { return fxRunnable; } 00099 00100 TCondition* GetCondition() const { return fxCondition; } 00101 00102 void SetPID(); 00103 00104 void SetSelfID(); 00105 00106 void SetWaiting(Bool_t mode=kTRUE) { fbIsWaiting=mode; } 00107 00113 Bool_t fbIsInternal; 00114 00116 Bool_t fbIsCreated; 00117 00119 Bool_t fbIsRunning; 00120 00122 Int_t fiThreadPID; 00123 00125 Long_t fiThreadSelfID; 00126 00128 Bool_t fbIsWaiting; 00129 00137 TGo4Runnable *fxRunnable; 00138 00139 TThread *fxThread; 00140 00141 TCondition *fxCondition; 00142 00143 private: 00144 TGo4Thread(); 00145 }; 00146 00147 #endif