v2.10-0 (21000JUN2005)

Go4ThreadManagerExample
Class TGo4TestRunnable


class TGo4TestRunnable
derived from TGo4Runnable

Example of a user defined runnable subclass. Method Run() _must_ be implemented.
Methods ThreadCatch and UnexpectedCatch _can_ be overridden to change default
exception behaviour.
This runnable is able to do different actions depending on the fiMode parameter set
in the ctor (good for easy testing). However, the usual way is to create a dedicated
runnable class for a dedicated purpose and pass different
runnable classes to the different go4 threads (see Go4TaskHandler package for examples).

Different actions in this runnable:
fiMode=0: Dummy
printout a message every 5 seconds.
fiMode=1: Kill and create
sleep 30s, then kill other threads- sleep 5s, then create other threads again
fiMode=2: Stop and start
sleep 10s, then stop other threads- sleep 10s, then start other threads again
fiMode=3: Aborting all
sleep 30s, then abort application by means of exception
fiMode=4: Histogramming
creates histogram, fills it with random gaussian and draws it on pad
depending on the runnable name ("Maker1", "Maker2"), different pads are used
Maker 1 deletes histogram again each time, Maker 2 keeps initial histogram
sleeps of 2s are used to slow down the action
fiMode=5: Recreator
Cancel and recreate one thread by name ("First Thread") every 15 s.
fiMode=6: Exception tester
sleep 60s, then throw different thread exceptions (latest: Restart exception)
fiMode=7: Histogram without drawing
create histogram, fill it with random and delete it again
for memory alloc tests independent from root gui
fiMode default: Undefined
throw logic exception

NOTE1: Members of the runnable (histogram, canvas) are not deleted when the
TThread is killed. The runnable exists independent from the thread.
NOTE2: The user just has to create own runnables and a threadmanager subclasses,
subclassing of TGo4Thread or other parts of the package are not required!

Author:
J. Adamczewski, Go4 project-DVEE-GSI Darmstadt, Germany, j.adamczewski@gsi.de
Version: 0.9
Since: jul 2000-oct 2001

Field Summary
 private Int_tfiMode
          mode number which can be used to create runnables
with different actions in Workfunc; useful for testing
without creating new subclasses of runnable...
 private TCanvas*fxCanvas
           
 private TH1D*fxHisto
           
 private TPad*fxPad
           

Fields inherited from class Go4ThreadManager.TGo4Runnable
fxGo4Thread, fxManager

Fields inherited from class TNamed
fName, fTitle

Constructor Summary
TGo4TestRunnable()
           
TGo4TestRunnable(const TGo4TestRunnable& right)
           
TGo4TestRunnable(Text_t* name, TGo4ThreadManager* man, Int_t mode)
           

Destructor Summary
 virtual synchronized ~TGo4TestRunnable()
           

Method Summary
 synchronized TGo4TestRunnable&operator=(const TGo4TestRunnable& right)
           
 protected virtual Int_tRun(void * ptr)
          The working function which runs in the
thread
 protected virtual voidThreadCatch(TGo4Exception& ex)
          catch for exceptions occuring in workfunc
 protected virtual voidUnexpectedCatch()
          catch for all unexcpected exceptions happening in
workfunc

Methods inherited from class Go4ThreadManager.TGo4Runnable
GetThread, GetThreadManager, operator=, PostRun, PreRun, SetThread

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

fiMode

private Int_t fiMode
mode number which can be used to create runnables
with different actions in Workfunc; useful for testing
without creating new subclasses of runnable...

fxCanvas

private TCanvas* fxCanvas

fxHisto

private TH1D* fxHisto

fxPad

private TPad* fxPad
Constructor Detail

TGo4TestRunnable

public TGo4TestRunnable()

TGo4TestRunnable

public TGo4TestRunnable(const TGo4TestRunnable& right)

TGo4TestRunnable

public TGo4TestRunnable(Text_t* name, TGo4ThreadManager* man, Int_t mode)
Method Detail

~TGo4TestRunnable

public virtual synchronized ~TGo4TestRunnable()
Method Detail

operator=

public synchronized TGo4TestRunnable& operator=(const TGo4TestRunnable& right)

Run

protected virtual Int_t Run(void * ptr)
The working function which runs in the
thread

ThreadCatch

protected virtual void ThreadCatch(TGo4Exception& ex)
catch for exceptions occuring in workfunc

UnexpectedCatch

protected virtual void UnexpectedCatch()
catch for all unexcpected exceptions happening in
workfunc

Association Links

to Class TPad

to Class TCanvas

to Class TH1D


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

30-06-2005