00001 // $Id: TGo4ThreadHandler.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 TGo4ThreadHandler_H 00015 #define TGo4ThreadHandler_H 00016 00017 #include "TNamed.h" 00018 00019 class TGo4Thread; 00020 class TIterator; 00021 class TObjArray; 00022 class TMutex; 00023 class TGo4ThreadManager; 00024 class TGo4Runnable; 00025 00040 class TGo4ThreadHandler : public TNamed { 00041 00042 public: 00043 TGo4ThreadHandler(const TGo4ThreadHandler &right); 00044 00045 TGo4ThreadHandler (const char* name, TGo4ThreadManager* parent); 00046 00047 virtual ~TGo4ThreadHandler(); 00048 00050 Bool_t AddThread (TGo4Thread* gthr); 00051 00053 Bool_t RemoveThread (const char* name); 00054 00057 Bool_t NewThread(const char* name, TGo4Runnable* runnable); 00058 00060 Int_t CreateAll(); 00061 00064 Bool_t Create(const char* thname); 00065 00067 Int_t CancelAll(); 00068 00071 Bool_t Cancel(const char* thname); 00072 00074 Int_t ReCreateAll(); 00075 00077 Bool_t ReCreate(const char* thname); 00078 00080 Int_t StartAll(); 00081 00084 Bool_t Start(const char* thname); 00085 00087 Int_t StopAll (); 00088 00092 Bool_t Stop(const char* thname); 00093 00096 Int_t DumpThreads(Int_t mode = 0); 00097 00099 TGo4Thread* GetThread(const char* name); 00100 00102 Int_t GetEntries(); 00103 00107 Bool_t AllCreated(); 00108 00111 Bool_t AllRunning(); 00112 00115 Bool_t AllWaiting(); 00116 00120 Bool_t IsOperating() const { return fbIsOperating; } 00121 00122 protected: 00123 00127 TGo4ThreadManager *fxManager; 00128 00129 private: 00130 00134 Bool_t fbIsOperating; 00135 00137 TMutex *fxListMutex; 00138 00140 TIterator *fxIterator; 00141 00143 TObjArray *fxArray; 00144 00151 TMutex *fxOperMutex; 00152 00153 TGo4ThreadHandler(); 00154 }; 00155 00156 #endif