GSI Object Oriented Online Offline (Go4) GO4-6.4.0
|
Go4 thread handler. More...
#include <TGo4ThreadHandler.h>
Public Member Functions | |
TGo4ThreadHandler (const char *name, TGo4ThreadManager *parent) | |
TGo4ThreadHandler (const TGo4ThreadHandler &right) | |
virtual | ~TGo4ThreadHandler () |
Bool_t | AddThread (TGo4Thread *gthr) |
Adds Reference to (externally created) thread to Thread List. | |
Bool_t | AllCreated () |
Returns true if all root threads in list are existing, i.e. | |
Bool_t | AllRunning () |
Returns true if all threads in list are running, i.e. | |
Bool_t | AllWaiting () |
Returns true if all threads in list are waiting, i.e. | |
Bool_t | Cancel (const char *thname) |
Cancels the ROOT Thread specified by the Go4 Thread of name 'name'. | |
Int_t | CancelAll () |
Cancel all Threads in the thread list. | |
Bool_t | Create (const char *thname) |
Launch the ROOT Thread specified by the Go4 Thread of name 'name'. | |
Int_t | CreateAll () |
Launch all Threads in the thread list. | |
Int_t | DumpThreads (Int_t mode=0) |
dumps thread process information to logging output i.e. | |
Int_t | GetEntries () const |
Number of threads in list. | |
TGo4Thread * | GetThread (const char *name) |
Access to Go4Thread by name. | |
Bool_t | IsOperating () const |
Returns kTRUE if threadhandler performs any action that requires gSystem support. | |
Bool_t | NewThread (const char *name, TGo4Runnable *runnable) |
Creates new internal Go4 Thread with name and adds it to the List External runnable is passed to specify the threaded actions. | |
Bool_t | ReCreate (const char *thname) |
ReCreate (Cancel and Create) all Threads in the thread list. | |
Int_t | ReCreateAll () |
Recreate all Threads in the thread list. | |
Bool_t | RemoveThread (const char *name) |
Remove thread by name from Thread List. | |
Bool_t | Start (const char *thname) |
Starts work function of the Go4 Thread of name 'name'. | |
Int_t | StartAll () |
Start work function of all Threads in the thread list. | |
Bool_t | Stop (const char *thname) |
Stops work function of the Go4 Thread of name 'name'. | |
Int_t | StopAll () |
Start work function of all Threads in the thread list. | |
Protected Attributes | |
TGo4ThreadManager * | fxManager {nullptr} |
Backlink to threadmanager who owns this thread handler. | |
Private Member Functions | |
TGo4ThreadHandler () | |
Private Attributes | |
Bool_t | fbIsOperating {kFALSE} |
kTRUE, if threadhandler performs any action that requires gSystem support. | |
TObjArray * | fxArray {nullptr} |
Array of Go4Threads. | |
TIterator * | fxIterator {nullptr} |
Iterator for Thread Array. | |
TMutex * | fxListMutex {nullptr} |
Mutex protecting thread array. | |
TMutex * | fxOperMutex {nullptr} |
Mutex to protect IsOperating flag, flag is set kTRUE to indicate that AppControl timer must not block, since thread launching or canceling operation is performed by thread handler. | |
Go4 thread handler.
Thread Handler holds array of Go4Thread Objects; each Go4Thread handles one TThread and Mutex, Condition... knows threadmanager instance that owns the handler (that owns the task connector which owns the thread handler, respectively) this threadmanager instance pointer is given to each thread and runnable on creation, thus each thread can access its manager methods by threadmanager pointer
Definition at line 42 of file TGo4ThreadHandler.h.
TGo4ThreadHandler::TGo4ThreadHandler | ( | const TGo4ThreadHandler & | right | ) |
Definition at line 24 of file TGo4ThreadHandler.cxx.
References TGo4ThreadHandler(), fxArray, fxIterator, fxListMutex, fxManager, fxOperMutex, and GO4TRACE.
Referenced by TGo4ThreadHandler().
TGo4ThreadHandler::TGo4ThreadHandler | ( | const char * | name, |
TGo4ThreadManager * | parent ) |
Definition at line 35 of file TGo4ThreadHandler.cxx.
References fbIsOperating, fxArray, fxIterator, fxListMutex, fxManager, fxOperMutex, and GO4TRACE.
|
virtual |
Definition at line 47 of file TGo4ThreadHandler.cxx.
References CancelAll(), fxArray, fxIterator, fxListMutex, fxOperMutex, GO4TRACE, TGo4Thread::IsInternal(), StopAll(), and TGo4LockGuard.
|
private |
Bool_t TGo4ThreadHandler::AddThread | ( | TGo4Thread * | gthr | ) |
Adds Reference to (externally created) thread to Thread List.
Definition at line 82 of file TGo4ThreadHandler.cxx.
References fxArray, fxListMutex, GO4TRACE, and TGo4LockGuard.
Referenced by NewThread().
Bool_t TGo4ThreadHandler::AllCreated | ( | ) |
Returns true if all root threads in list are existing, i.e.
there is a pid and a valid thread pointer for them in go4 thread
Definition at line 497 of file TGo4ThreadHandler.cxx.
References fxIterator, fxListMutex, TGo4Thread::GetPID(), GO4TRACE, and TGo4LockGuard.
Bool_t TGo4ThreadHandler::AllRunning | ( | ) |
Returns true if all threads in list are running, i.e.
all workfunctions were started
Definition at line 523 of file TGo4ThreadHandler.cxx.
References fxIterator, fxListMutex, GO4TRACE, TGo4Thread::IsRunning(), and TGo4LockGuard.
Bool_t TGo4ThreadHandler::AllWaiting | ( | ) |
Returns true if all threads in list are waiting, i.e.
all workfunctions are in condition wait
Definition at line 549 of file TGo4ThreadHandler.cxx.
References fxIterator, fxListMutex, GO4TRACE, TGo4Thread::IsWaiting(), and TGo4LockGuard.
Bool_t TGo4ThreadHandler::Cancel | ( | const char * | thname | ) |
Cancels the ROOT Thread specified by the Go4 Thread of name 'name'.
Name of TThread and TGo4Thread is the same.
Definition at line 238 of file TGo4ThreadHandler.cxx.
References TGo4Thread::Cancel(), fbIsOperating, fxManager, fxOperMutex, GetThread(), GO4TRACE, and TGo4LockGuard.
Referenced by TGo4AnalysisClient::KillMain(), TGo4TestRunnable::Run(), and TGo4AnalysisClient::TerminateFast().
Int_t TGo4ThreadHandler::CancelAll | ( | ) |
Cancel all Threads in the thread list.
Definition at line 214 of file TGo4ThreadHandler.cxx.
References TGo4Thread::Cancel(), fbIsOperating, fxIterator, fxListMutex, fxOperMutex, GO4TRACE, and TGo4LockGuard.
Referenced by TGo4AnalysisClient::~TGo4AnalysisClient(), TGo4Display::~TGo4Display(), TGo4ServerTask::~TGo4ServerTask(), and ~TGo4ThreadHandler().
Bool_t TGo4ThreadHandler::Create | ( | const char * | thname | ) |
Launch the ROOT Thread specified by the Go4 Thread of name 'name'.
Name of TThread and TGo4Thread is the same.
Definition at line 189 of file TGo4ThreadHandler.cxx.
References TGo4Thread::Create(), fbIsOperating, fxManager, fxOperMutex, GetThread(), GO4TRACE, and TGo4LockGuard.
Referenced by TGo4TestRunnable::Run().
Int_t TGo4ThreadHandler::CreateAll | ( | ) |
Launch all Threads in the thread list.
Definition at line 159 of file TGo4ThreadHandler.cxx.
References TGo4Thread::Create(), fbIsOperating, fxIterator, fxListMutex, fxManager, fxOperMutex, GO4TRACE, and TGo4LockGuard.
Int_t TGo4ThreadHandler::DumpThreads | ( | Int_t | mode = 0 | ) |
dumps thread process information to logging output i.e.
file or anything
Definition at line 419 of file TGo4ThreadHandler.cxx.
References TGo4Log::Debug(), fxIterator, fxListMutex, TGo4Log::GetIgnoreLevel(), TGo4Thread::GetPID(), TGo4Thread::GetSelfID(), GO4TRACE, and TGo4LockGuard.
Int_t TGo4ThreadHandler::GetEntries | ( | ) | const |
Number of threads in list.
Definition at line 486 of file TGo4ThreadHandler.cxx.
References fxArray, fxListMutex, GO4TRACE, and TGo4LockGuard.
TGo4Thread * TGo4ThreadHandler::GetThread | ( | const char * | name | ) |
Access to Go4Thread by name.
Definition at line 475 of file TGo4ThreadHandler.cxx.
References fxArray, fxListMutex, GO4TRACE, and TGo4LockGuard.
Referenced by Cancel(), TGo4ServerTask::ConnectorThreadIsStopped(), Create(), ReCreate(), Start(), and Stop().
|
inline |
Returns kTRUE if threadhandler performs any action that requires gSystem support.
Flag is checked by Manager before Blocking the System.
Definition at line 122 of file TGo4ThreadHandler.h.
References fbIsOperating.
Bool_t TGo4ThreadHandler::NewThread | ( | const char * | name, |
TGo4Runnable * | runnable ) |
Creates new internal Go4 Thread with name and adds it to the List External runnable is passed to specify the threaded actions.
Definition at line 139 of file TGo4ThreadHandler.cxx.
References AddThread(), and GO4TRACE.
Referenced by TGo4Task::TGo4Task(), and TGo4AnalysisClient::Constructor().
Bool_t TGo4ThreadHandler::ReCreate | ( | const char * | thname | ) |
ReCreate (Cancel and Create) all Threads in the thread list.
Definition at line 289 of file TGo4ThreadHandler.cxx.
References fbIsOperating, fxManager, fxOperMutex, GetThread(), GO4TRACE, TGo4Thread::ReCreate(), and TGo4LockGuard.
Referenced by TGo4AnalysisClient::RestartMain().
Int_t TGo4ThreadHandler::ReCreateAll | ( | ) |
Recreate all Threads in the thread list.
Definition at line 260 of file TGo4ThreadHandler.cxx.
References fbIsOperating, fxIterator, fxListMutex, fxOperMutex, GO4TRACE, TGo4Thread::ReCreate(), and TGo4LockGuard.
Bool_t TGo4ThreadHandler::RemoveThread | ( | const char * | name | ) |
Remove thread by name from Thread List.
Definition at line 103 of file TGo4ThreadHandler.cxx.
References fbIsOperating, fxArray, fxListMutex, fxManager, fxOperMutex, GO4TRACE, TGo4Thread::IsInternal(), and TGo4LockGuard.
Bool_t TGo4ThreadHandler::Start | ( | const char * | thname | ) |
Starts work function of the Go4 Thread of name 'name'.
Workfunction will run in infinite loop until Stop().
Definition at line 346 of file TGo4ThreadHandler.cxx.
References fbIsOperating, fxManager, fxOperMutex, GetThread(), GO4TRACE, TGo4Thread::Start(), and TGo4LockGuard.
Referenced by TGo4AnalysisClient::RestartMain(), TGo4TestRunnable::Run(), TGo4AnalysisClient::Start(), TGo4ServerTask::StartConnectorThread(), TGo4AnalysisClient::StartWorkThreads(), and TGo4ExampleServer::StartWorkThreads().
Int_t TGo4ThreadHandler::StartAll | ( | ) |
Start work function of all Threads in the thread list.
Definition at line 315 of file TGo4ThreadHandler.cxx.
References fbIsOperating, fxIterator, fxListMutex, fxManager, fxOperMutex, GO4TRACE, TGo4Thread::Start(), and TGo4LockGuard.
Bool_t TGo4ThreadHandler::Stop | ( | const char * | thname | ) |
Stops work function of the Go4 Thread of name 'name'.
Thread will suspend to condition wait without being killed. Workfunction will continue loop on next Start().
Definition at line 399 of file TGo4ThreadHandler.cxx.
References GetThread(), GO4TRACE, and TGo4Thread::Stop().
Referenced by TGo4AnalysisClient::KillMain(), TGo4AnalysisClient::RestartMain(), TGo4TestRunnable::Run(), TGo4ServerTask::StopConnectorThread(), TGo4AnalysisClient::StopWorkThreads(), and TGo4ExampleServer::StopWorkThreads().
Int_t TGo4ThreadHandler::StopAll | ( | ) |
Start work function of all Threads in the thread list.
Definition at line 371 of file TGo4ThreadHandler.cxx.
References fxIterator, fxListMutex, GO4TRACE, TGo4Thread::Stop(), and TGo4LockGuard.
Referenced by ~TGo4ThreadHandler(), and TGo4AnalysisClient::TerminateFast().
|
private |
kTRUE, if threadhandler performs any action that requires gSystem support.
Flag is checked by Manager before Blocking the System using IsOperating() method
Definition at line 136 of file TGo4ThreadHandler.h.
Referenced by TGo4ThreadHandler(), Cancel(), CancelAll(), Create(), CreateAll(), IsOperating(), ReCreate(), ReCreateAll(), RemoveThread(), Start(), and StartAll().
|
private |
Array of Go4Threads.
Definition at line 145 of file TGo4ThreadHandler.h.
Referenced by TGo4ThreadHandler(), TGo4ThreadHandler(), ~TGo4ThreadHandler(), AddThread(), GetEntries(), GetThread(), and RemoveThread().
|
private |
Iterator for Thread Array.
Definition at line 142 of file TGo4ThreadHandler.h.
Referenced by TGo4ThreadHandler(), TGo4ThreadHandler(), ~TGo4ThreadHandler(), AllCreated(), AllRunning(), AllWaiting(), CancelAll(), CreateAll(), DumpThreads(), ReCreateAll(), StartAll(), and StopAll().
|
private |
Mutex protecting thread array.
Definition at line 139 of file TGo4ThreadHandler.h.
Referenced by TGo4ThreadHandler(), TGo4ThreadHandler(), ~TGo4ThreadHandler(), AddThread(), AllCreated(), AllRunning(), AllWaiting(), CancelAll(), CreateAll(), DumpThreads(), GetEntries(), GetThread(), ReCreateAll(), RemoveThread(), StartAll(), and StopAll().
|
protected |
Backlink to threadmanager who owns this thread handler.
1 1
Definition at line 129 of file TGo4ThreadHandler.h.
Referenced by TGo4ThreadHandler(), TGo4ThreadHandler(), Cancel(), Create(), CreateAll(), ReCreate(), RemoveThread(), Start(), and StartAll().
|
private |
Mutex to protect IsOperating flag, flag is set kTRUE to indicate that AppControl timer must not block, since thread launching or canceling operation is performed by thread handler.
This state is checked by threadmanager in BlockApp() method before enabling timer wait. Mechanism should prevent timer deadlocks.
Definition at line 153 of file TGo4ThreadHandler.h.
Referenced by TGo4ThreadHandler(), TGo4ThreadHandler(), ~TGo4ThreadHandler(), Cancel(), CancelAll(), Create(), CreateAll(), ReCreate(), ReCreateAll(), RemoveThread(), Start(), and StartAll().