GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4Thread.h
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #ifndef TGo4Thread_H
15 #define TGo4Thread_H
16 
17 #include "TNamed.h"
18 
19 class TThread;
20 class TCondition;
21 class TGo4Runnable;
22 
32 class TGo4Thread : public TNamed {
33 
34  public:
35 
36  TGo4Thread() = delete;
37 
38  TGo4Thread(const TGo4Thread &right);
39 
45  TGo4Thread (const char *name, TGo4Runnable *runnable, Bool_t internal = kTRUE);
46 
47  virtual ~TGo4Thread();
48 
50  Bool_t Create();
51 
53  Bool_t Cancel();
54 
58  Bool_t ReCreate();
59 
62  Bool_t Start();
63 
65  Bool_t Stop();
66 
69  static void Sleep(UInt_t millisecs);
70 
72  Int_t GetPID() const { return fiThreadPID; }
73 
75  Long_t GetSelfID() const { return fiThreadSelfID; }
76 
79  Bool_t IsInternal() const { return fbIsInternal; }
80 
82  Bool_t IsCreated() const { return fbIsCreated; }
83 
85  Bool_t IsRunning() const { return fbIsRunning; }
86 
88  Bool_t IsWaiting() const { return fbIsWaiting; }
89 
90  private:
91 
96  static void Threadfunc (void *arg);
97 
99  TGo4Runnable *GetRunnable() const { return fxRunnable; }
100 
101  TCondition *GetCondition() const { return fxCondition; }
102 
103  void SetPID();
104 
105  void SetSelfID();
106 
107  void SetWaiting(Bool_t mode=kTRUE) { fbIsWaiting=mode; }
108 
114  Bool_t fbIsInternal{kFALSE};
115 
117  Bool_t fbIsCreated{kFALSE};
118 
120  Bool_t fbIsRunning{kFALSE};
121 
123  Int_t fiThreadPID{0};
124 
126  Long_t fiThreadSelfID{0};
127 
129  Bool_t fbIsWaiting{kFALSE};
130 
139 
140  TThread *fxThread{nullptr};
141 
142  TCondition *fxCondition{nullptr};
143 };
144 
145 #endif
Bool_t Stop()
Definition: TGo4Thread.cxx:287
void SetWaiting(Bool_t mode=kTRUE)
Definition: TGo4Thread.h:107
Bool_t Cancel()
Definition: TGo4Thread.cxx:183
static void Sleep(UInt_t millisecs)
Definition: TGo4Thread.cxx:295
static void Threadfunc(void *arg)
Definition: TGo4Thread.cxx:75
TGo4Thread()=delete
Bool_t IsCreated() const
Definition: TGo4Thread.h:82
Long_t GetSelfID() const
Definition: TGo4Thread.h:75
TThread * fxThread
Definition: TGo4Thread.h:140
TCondition * fxCondition
Definition: TGo4Thread.h:142
Bool_t IsRunning() const
Definition: TGo4Thread.h:85
Bool_t IsWaiting() const
Definition: TGo4Thread.h:88
void SetPID()
Definition: TGo4Thread.cxx:307
TCondition * GetCondition() const
Definition: TGo4Thread.h:101
Long_t fiThreadSelfID
Definition: TGo4Thread.h:126
virtual ~TGo4Thread()
Definition: TGo4Thread.cxx:52
TGo4Runnable * fxRunnable
Definition: TGo4Thread.h:138
Int_t fiThreadPID
Definition: TGo4Thread.h:123
Bool_t fbIsRunning
Definition: TGo4Thread.h:120
Bool_t ReCreate()
Definition: TGo4Thread.cxx:215
Bool_t fbIsInternal
Definition: TGo4Thread.h:114
Bool_t Create()
Definition: TGo4Thread.cxx:168
Bool_t fbIsCreated
Definition: TGo4Thread.h:117
void SetSelfID()
Definition: TGo4Thread.cxx:302
Bool_t Start()
Definition: TGo4Thread.cxx:269
TGo4Runnable * GetRunnable() const
Definition: TGo4Thread.h:99
Bool_t fbIsWaiting
Definition: TGo4Thread.h:129
Bool_t IsInternal() const
Definition: TGo4Thread.h:79
Int_t GetPID() const
Definition: TGo4Thread.h:72