v2.10-0 (21000JUN2005)

Go4ThreadManager
Class TGo4ThreadHandler


class TGo4ThreadHandler
derived from TNamed

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, Go4 project-DVEE-GSI Darmstadt, Germany, j.adamczewski@gsi.de
Version: 0.9
Since: jul 2000-oct 2001

Field Summary
 private Bool_tfbIsOperating
          kTRUE, if threadhandler performs any action that
requires gSystem support.
 private TObjArray*fxArray
          Array of Go4Threads
 private TIterator*fxIterator
          Iterator for Thread Array
 private TMutex*fxListMutex
          Mutex protecting thread array
 protected TGo4ThreadManager*fxManager
          Backlink to threadmanager who owns this thread handler.
 private TMutex*fxOperMutex
          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.

Fields inherited from class TNamed
fName, fTitle

Constructor Summary
 TGo4ThreadHandler(const TGo4ThreadHandler& right)
           
 TGo4ThreadHandler(const char * name, TGo4ThreadManager* parent)
           
 private TGo4ThreadHandler()
           

Destructor Summary
 virtual synchronized ~TGo4ThreadHandler()
           

Method Summary
 Bool_tAddThread(TGo4Thread* gthr)
          Adds Reference to (externally created) thread
to Thread List
 Bool_tAllCreated()
          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
 Bool_tAllRunning()
          Returns true if all threads in list are running, i.e.
all workfunctions were started
 Bool_tAllWaiting()
          Returns true if all threads in list are waiting, i.e.
all workfunctions are in condition wait
 Bool_tCancel(const char * thname)
          Cancels the ROOT Thread specified by the Go4 Thread of name 'name'.
 Int_tCancelAll()
          Cancel all Threads in the thread list.
 Bool_tCreate(const char * thname)
          Launch the ROOT Thread specified by the Go4 Thread of name 'name'.
 Int_tCreateAll()
          Launch all Threads in the thread list.
 Int_tDumpThreads(Int_t mode)
          dumps thread process information to logging output
i.e. file or anything
 Int_tGetEntries()
          Number of threads in list
 TGo4Thread*GetThread(const char * name)
          Access to Go4Thread by name.
 const Bool_tIsOperating()
          Returns kTRUE if threadhandler performs any action that
requires gSystem support.
 Bool_tNewThread(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_tReCreate(const char * thname)
          ReCreate (Cancel and Create) all Threads in the thread list.
 Int_tReCreateAll()
          Recreate all Threads in the thread list.
 Bool_tRemoveThread(const char * name)
          Remove thread by name
from Thread List
 Bool_tStart(const char * thname)
          Starts work function of the Go4 Thread of name 'name'.
 Int_tStartAll()
          Start work function of all Threads in the thread list.
 Bool_tStop(const char * thname)
          Stops work function of the Go4 Thread of name 'name'.
 Int_tStopAll()
          Start work function of all Threads in the thread list.

Methods inherited from class TNamed
operator=, Clear, Clone, Compare, Copy, FillBuffer, GetName, GetTitle, Hash, IsSortable, SetName, SetNameTitle, SetTitle, ls, Print, Sizeof, Class, Class_Name, Class_Version, Dictionary, IsA, ShowMembers, Streamer, StreamerNVirtual, DeclFileName, ImplFileLine, ImplFileName, DeclFileLine

Field Detail

fbIsOperating

private Bool_t fbIsOperating
kTRUE, if threadhandler performs any action that
requires gSystem support. Flag is checked by Manager
before Blocking the System using IsOperating() method

fxArray

private TObjArray* fxArray
Array of Go4Threads

fxIterator

private TIterator* fxIterator
Iterator for Thread Array

fxListMutex

private TMutex* fxListMutex
Mutex protecting thread array

fxManager

protected TGo4ThreadManager* fxManager
Backlink to threadmanager who owns this thread handler.
supplierCardinality 1
clientCardinality 1

fxOperMutex

private TMutex* fxOperMutex
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.
Constructor Detail

TGo4ThreadHandler

public TGo4ThreadHandler(const TGo4ThreadHandler& right)

TGo4ThreadHandler

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

TGo4ThreadHandler

private TGo4ThreadHandler()
Method Detail

~TGo4ThreadHandler

public virtual synchronized ~TGo4ThreadHandler()
Method Detail

AddThread

public Bool_t AddThread(TGo4Thread* gthr)
Adds Reference to (externally created) thread
to Thread List

AllCreated

public Bool_t 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

AllRunning

public Bool_t AllRunning()
Returns true if all threads in list are running, i.e.
all workfunctions were started

AllWaiting

public Bool_t AllWaiting()
Returns true if all threads in list are waiting, i.e.
all workfunctions are in condition wait

Cancel

public Bool_t Cancel(const char * thname)
Cancels the ROOT Thread specified by the Go4 Thread of name 'name'.
Name of TThread and TGo4Thread is the same.

CancelAll

public Int_t CancelAll()
Cancel all Threads in the thread list.

Create

public Bool_t Create(const char * thname)
Launch the ROOT Thread specified by the Go4 Thread of name 'name'.
Name of TThread and TGo4Thread is the same.

CreateAll

public Int_t CreateAll()
Launch all Threads in the thread list.

DumpThreads

public Int_t DumpThreads(Int_t mode)
dumps thread process information to logging output
i.e. file or anything

GetEntries

public Int_t GetEntries()
Number of threads in list

GetThread

public TGo4Thread* GetThread(const char * name)
Access to Go4Thread by name.

IsOperating

public const Bool_t IsOperating()
Returns kTRUE if threadhandler performs any action that
requires gSystem support. Flag is checked by Manager
before Blocking the System.

NewThread

public 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

ReCreate

public Bool_t ReCreate(const char * thname)
ReCreate (Cancel and Create) all Threads in the thread list.

ReCreateAll

public Int_t ReCreateAll()
Recreate all Threads in the thread list.

RemoveThread

public Bool_t RemoveThread(const char * name)
Remove thread by name
from Thread List

Start

public Bool_t Start(const char * thname)
Starts work function of the Go4 Thread of name 'name'.
Workfunction will run in infinite loop until Stop().

StartAll

public Int_t StartAll()
Start work function of all Threads in the thread list.

Stop

public Bool_t 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().

StopAll

public Int_t StopAll()
Start work function of all Threads in the thread list.

Association Links

to Class TGo4ThreadManager

Backlink to threadmanager who owns this thread handler.

Client Cardinality 1
Supplier Cardinality 1

to Class TMutex

Mutex protecting thread array

to Class TIterator

Iterator for Thread Array

to Class TObjArray

Array of Go4Threads

to Class TMutex

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.

J.Adamczewski, M.Al-Turany, D.Bertini, H.G.Essel, S.Linev

30-06-2005