00001 // $Id: TGo4Thread.h 1196 2014-04-10 14:06:24Z 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 00032 class TGo4Thread : public TNamed { 00033 00034 public: 00035 00036 TGo4Thread(const TGo4Thread &right); 00037 00043 TGo4Thread (const char* name, TGo4Runnable* runnable, Bool_t internal = kTRUE); 00044 00045 virtual ~TGo4Thread(); 00046 00048 Bool_t Create(); 00049 00051 Bool_t Cancel(); 00052 00056 Bool_t ReCreate(); 00057 00060 Bool_t Start(); 00061 00063 Bool_t Stop(); 00064 00067 static void Sleep(UInt_t millisecs); 00068 00070 Int_t GetPID() const { return fiThreadPID; } 00071 00073 Long_t GetSelfID() const { return fiThreadSelfID; } 00074 00077 Bool_t IsInternal() const { return fbIsInternal; } 00078 00080 Bool_t IsCreated() const { return fbIsCreated; } 00081 00083 Bool_t IsRunning() const { return fbIsRunning; } 00084 00086 Bool_t IsWaiting() const { return fbIsWaiting; } 00087 00088 private: 00089 00094 static void Threadfunc (void* arg); 00095 00097 TGo4Runnable* GetRunnable() const { return fxRunnable; } 00098 00099 TCondition* GetCondition() const { return fxCondition; } 00100 00101 void SetPID(); 00102 00103 void SetSelfID(); 00104 00105 void SetWaiting(Bool_t mode=kTRUE) { fbIsWaiting=mode; } 00106 00112 Bool_t fbIsInternal; 00113 00115 Bool_t fbIsCreated; 00116 00118 Bool_t fbIsRunning; 00119 00121 Int_t fiThreadPID; 00122 00124 Long_t fiThreadSelfID; 00125 00127 Bool_t fbIsWaiting; 00128 00136 TGo4Runnable *fxRunnable; 00137 00138 TThread *fxThread; 00139 00140 TCondition *fxCondition; 00141 00142 private: 00143 TGo4Thread(); 00144 }; 00145 00146 #endif