00001 // $Id: TGo4ThreadHandler.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 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 00041 class TGo4ThreadHandler : public TNamed { 00042 00043 public: 00044 TGo4ThreadHandler(const TGo4ThreadHandler &right); 00045 00046 TGo4ThreadHandler (const char* name, TGo4ThreadManager* parent); 00047 00048 virtual ~TGo4ThreadHandler(); 00049 00051 Bool_t AddThread (TGo4Thread* gthr); 00052 00054 Bool_t RemoveThread (const char* name); 00055 00058 Bool_t NewThread(const char* name, TGo4Runnable* runnable); 00059 00061 Int_t CreateAll(); 00062 00065 Bool_t Create(const char* thname); 00066 00068 Int_t CancelAll(); 00069 00072 Bool_t Cancel(const char* thname); 00073 00075 Int_t ReCreateAll(); 00076 00078 Bool_t ReCreate(const char* thname); 00079 00081 Int_t StartAll(); 00082 00085 Bool_t Start(const char* thname); 00086 00088 Int_t StopAll (); 00089 00093 Bool_t Stop(const char* thname); 00094 00097 Int_t DumpThreads(Int_t mode = 0); 00098 00100 TGo4Thread* GetThread(const char* name); 00101 00103 Int_t GetEntries(); 00104 00108 Bool_t AllCreated(); 00109 00112 Bool_t AllRunning(); 00113 00116 Bool_t AllWaiting(); 00117 00121 Bool_t IsOperating() const { return fbIsOperating; } 00122 00123 protected: 00124 00128 TGo4ThreadManager *fxManager; 00129 00130 private: 00131 00135 Bool_t fbIsOperating; 00136 00138 TMutex *fxListMutex; 00139 00141 TIterator *fxIterator; 00142 00144 TObjArray *fxArray; 00145 00152 TMutex *fxOperMutex; 00153 00154 TGo4ThreadHandler(); 00155 }; 00156 00157 #endif