GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
TGo4ThreadHandler Class Reference

#include <TGo4ThreadHandler.h>

+ Inheritance diagram for TGo4ThreadHandler:

Public Member Functions

 TGo4ThreadHandler (const TGo4ThreadHandler &right)
 
 TGo4ThreadHandler (const char *name, TGo4ThreadManager *parent)
 
virtual ~TGo4ThreadHandler ()
 
Bool_t AddThread (TGo4Thread *gthr)
 
Bool_t RemoveThread (const char *name)
 
Bool_t NewThread (const char *name, TGo4Runnable *runnable)
 
Int_t CreateAll ()
 
Bool_t Create (const char *thname)
 
Int_t CancelAll ()
 
Bool_t Cancel (const char *thname)
 
Int_t ReCreateAll ()
 
Bool_t ReCreate (const char *thname)
 
Int_t StartAll ()
 
Bool_t Start (const char *thname)
 
Int_t StopAll ()
 
Bool_t Stop (const char *thname)
 
Int_t DumpThreads (Int_t mode=0)
 
TGo4ThreadGetThread (const char *name)
 
Int_t GetEntries ()
 
Bool_t AllCreated ()
 
Bool_t AllRunning ()
 
Bool_t AllWaiting ()
 
Bool_t IsOperating () const
 

Protected Attributes

TGo4ThreadManagerfxManager
 

Private Member Functions

 TGo4ThreadHandler ()
 

Private Attributes

Bool_t fbIsOperating
 
TMutex * fxListMutex
 
TIterator * fxIterator
 
TObjArray * fxArray
 
TMutex * fxOperMutex
 

Detailed Description

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 acces its manager methods by threadmanager pointer

Author
J. Adamczewski(at)gsi.de
Go4 project-DVEE-GSI Darmstadt
Germany
Version
0.9
Since
jul 2000-oct 2001

Definition at line 40 of file TGo4ThreadHandler.h.

Constructor & Destructor Documentation

TGo4ThreadHandler::TGo4ThreadHandler ( const TGo4ThreadHandler right)

Definition at line 25 of file TGo4ThreadHandler.cxx.

References fxArray, fxIterator, fxListMutex, fxManager, fxOperMutex, and GO4TRACE.

TGo4ThreadHandler::TGo4ThreadHandler ( const char *  name,
TGo4ThreadManager parent 
)

Definition at line 36 of file TGo4ThreadHandler.cxx.

References fxArray, fxIterator, fxListMutex, fxManager, fxOperMutex, and GO4TRACE.

TGo4ThreadHandler::~TGo4ThreadHandler ( )
virtual
TGo4ThreadHandler::TGo4ThreadHandler ( )
private

Member Function Documentation

Bool_t TGo4ThreadHandler::AddThread ( TGo4Thread gthr)

Adds Reference to (externally created) thread to Thread List

Definition at line 83 of file TGo4ThreadHandler.cxx.

References fxArray, fxListMutex, and GO4TRACE.

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 518 of file TGo4ThreadHandler.cxx.

References fxIterator, fxListMutex, TGo4Thread::GetPID(), and GO4TRACE.

Referenced by TGo4ThreadManager::Initialization().

Bool_t TGo4ThreadHandler::AllRunning ( )

Returns true if all threads in list are running, i.e. all workfunctions were started

Definition at line 544 of file TGo4ThreadHandler.cxx.

References fxIterator, fxListMutex, GO4TRACE, and TGo4Thread::IsRunning().

Bool_t TGo4ThreadHandler::AllWaiting ( )

Returns true if all threads in list are waiting, i.e. all workfunctions are in condition wait

Definition at line 570 of file TGo4ThreadHandler.cxx.

References fxIterator, fxListMutex, GO4TRACE, and TGo4Thread::IsWaiting().

Referenced by TGo4AppControlTimer::Notify().

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 253 of file TGo4ThreadHandler.cxx.

References TGo4ThreadManager::BlockApp(), TGo4Thread::Cancel(), fbIsOperating, fxManager, fxOperMutex, GetThread(), GO4TRACE, and TGo4ThreadManager::UnBlockApp().

Referenced by TGo4CancelException::Handle(), TGo4AnalysisClient::KillMain(), TGo4TestRunnable::Run(), and TGo4AnalysisClient::TerminateFast().

Int_t TGo4ThreadHandler::CancelAll ( )
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 199 of file TGo4ThreadHandler.cxx.

References TGo4ThreadManager::BlockApp(), TGo4Thread::Create(), fbIsOperating, fxManager, fxOperMutex, GetThread(), GO4TRACE, and TGo4ThreadManager::UnBlockApp().

Referenced by TGo4CreateException::Handle(), and TGo4TestRunnable::Run().

Int_t TGo4ThreadHandler::CreateAll ( )
Int_t TGo4ThreadHandler::DumpThreads ( Int_t  mode = 0)

dumps thread process information to logging output i.e. file or anything

Definition at line 440 of file TGo4ThreadHandler.cxx.

References TGo4Log::Debug(), fxIterator, fxListMutex, TGo4Log::GetIgnoreLevel(), TGo4Thread::GetPID(), TGo4Thread::GetSelfID(), and GO4TRACE.

Referenced by TGo4ThreadManager::Initialization().

Int_t TGo4ThreadHandler::GetEntries ( )

Number of threads in list

Definition at line 507 of file TGo4ThreadHandler.cxx.

References fxArray, fxListMutex, and GO4TRACE.

TGo4Thread * TGo4ThreadHandler::GetThread ( const char *  name)

Access to Go4Thread by name.

Definition at line 496 of file TGo4ThreadHandler.cxx.

References fxArray, fxListMutex, and GO4TRACE.

Referenced by Cancel(), TGo4ServerTask::ConnectorThreadIsStopped(), Create(), ReCreate(), Start(), Stop(), and TGo4TaskHandler::WaitThreadStop().

Bool_t TGo4ThreadHandler::IsOperating ( ) const
inline

Returns kTRUE if threadhandler performs any action that requires gSystem support. Flag is checked by Manager before Blocking the System.

Definition at line 120 of file TGo4ThreadHandler.h.

References fbIsOperating.

Referenced by TGo4ThreadManager::BlockApp().

Bool_t TGo4ThreadHandler::NewThread ( const char *  name,
TGo4Runnable runnable 
)
Bool_t TGo4ThreadHandler::ReCreate ( const char *  thname)
Int_t TGo4ThreadHandler::ReCreateAll ( )

Recreate all Threads in the thread list.

Definition at line 278 of file TGo4ThreadHandler.cxx.

References fbIsOperating, fxIterator, fxListMutex, fxOperMutex, GO4TRACE, and TGo4Thread::ReCreate().

Bool_t TGo4ThreadHandler::RemoveThread ( const char *  name)
Bool_t TGo4ThreadHandler::Start ( const char *  thname)
Int_t TGo4ThreadHandler::StartAll ( )
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 Sart().

Definition at line 420 of file TGo4ThreadHandler.cxx.

References GetThread(), GO4TRACE, and TGo4Thread::Stop().

Referenced by TGo4AnalysisClient::KillMain(), TGo4AnalysisClient::RestartMain(), TGo4TestRunnable::Run(), TGo4ExampleClient::Stop(), TGo4ServerTask::StopConnectorThread(), TGo4TaskHandler::StopTransportThreads(), TGo4ExampleServer::StopWorkThreads(), TGo4AnalysisClient::StopWorkThreads(), and TGo4HistogramServer::~TGo4HistogramServer().

Int_t TGo4ThreadHandler::StopAll ( )

Start work function of all Threads in the thread list.

Definition at line 392 of file TGo4ThreadHandler.cxx.

References fxIterator, fxListMutex, GO4TRACE, and TGo4Thread::Stop().

Referenced by TGo4AppControlTimer::Notify(), TGo4ThreadManager::Terminate(), TGo4AnalysisClient::TerminateFast(), and ~TGo4ThreadHandler().

Member Data Documentation

Bool_t TGo4ThreadHandler::fbIsOperating
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 134 of file TGo4ThreadHandler.h.

Referenced by Cancel(), CancelAll(), Create(), CreateAll(), IsOperating(), ReCreate(), ReCreateAll(), RemoveThread(), Start(), and StartAll().

TObjArray* TGo4ThreadHandler::fxArray
private

Array of Go4Threads

Definition at line 143 of file TGo4ThreadHandler.h.

Referenced by AddThread(), GetEntries(), GetThread(), RemoveThread(), TGo4ThreadHandler(), and ~TGo4ThreadHandler().

TIterator* TGo4ThreadHandler::fxIterator
private
TMutex* TGo4ThreadHandler::fxListMutex
private
TGo4ThreadManager* TGo4ThreadHandler::fxManager
protected

Backlink to threadmanager who owns this thread handler. 1 1

Definition at line 127 of file TGo4ThreadHandler.h.

Referenced by Cancel(), Create(), CreateAll(), ReCreate(), RemoveThread(), Start(), StartAll(), and TGo4ThreadHandler().

TMutex* TGo4ThreadHandler::fxOperMutex
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 151 of file TGo4ThreadHandler.h.

Referenced by Cancel(), CancelAll(), Create(), CreateAll(), ReCreate(), ReCreateAll(), RemoveThread(), Start(), StartAll(), TGo4ThreadHandler(), and ~TGo4ThreadHandler().


The documentation for this class was generated from the following files: