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 Member Functions | Private Attributes | List of all members
TGo4TestRunnable Class Reference

#include <TGo4TestRunnable.h>

+ Inheritance diagram for TGo4TestRunnable:

Public Member Functions

 TGo4TestRunnable ()
 
 TGo4TestRunnable (const TGo4TestRunnable &right)
 
 TGo4TestRunnable (const char *name, TGo4ThreadManager *man, Int_t mode=0)
 
virtual ~TGo4TestRunnable ()
 
- Public Member Functions inherited from TGo4Runnable
 TGo4Runnable (const TGo4Runnable &right)
 
 TGo4Runnable (const char *name, TGo4ThreadManager *man)
 
virtual ~TGo4Runnable ()
 
void SetThread (TGo4Thread *gthread)
 
TGo4ThreadGetThread () const
 
TGo4ThreadManagerGetThreadManager () const
 

Protected Member Functions

virtual Int_t Run (void *ptr)
 
virtual void ThreadCatch (TGo4Exception &ex)
 
virtual void UnexpectedCatch ()
 
- Protected Member Functions inherited from TGo4Runnable
 TGo4Runnable ()
 
virtual Int_t PreRun (void *ptr)
 
virtual Int_t PostRun (void *ptr)
 

Private Attributes

Int_t fiMode
 
TPad * fxPad
 
TCanvas * fxCanvas
 
TH1D * fxHisto
 

Additional Inherited Members

- Protected Attributes inherited from TGo4Runnable
TGo4ThreadManagerfxManager
 
TGo4ThreadfxGo4Thread
 

Detailed Description

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(at)gsi.de
Go4 project-DVEE-GSI Darmstadt
Germany
Version
0.9
Since
jul 2000-oct 2001

Definition at line 67 of file TGo4TestRunnable.h.

Constructor & Destructor Documentation

TGo4TestRunnable::TGo4TestRunnable ( )

Definition at line 32 of file TGo4TestRunnable.cxx.

References GO4TRACE.

Referenced by Run().

TGo4TestRunnable::TGo4TestRunnable ( const TGo4TestRunnable right)

Definition at line 38 of file TGo4TestRunnable.cxx.

References fiMode, and GO4TRACE.

TGo4TestRunnable::TGo4TestRunnable ( const char *  name,
TGo4ThreadManager man,
Int_t  mode = 0 
)

Definition at line 45 of file TGo4TestRunnable.cxx.

References fiMode, and GO4TRACE.

TGo4TestRunnable::~TGo4TestRunnable ( )
virtual

Definition at line 53 of file TGo4TestRunnable.cxx.

References GO4TRACE.

Member Function Documentation

Int_t TGo4TestRunnable::Run ( void *  ptr)
protectedvirtual
void TGo4TestRunnable::ThreadCatch ( TGo4Exception ex)
protectedvirtual

catch for exceptions occuring in workfunc

Reimplemented from TGo4Runnable.

Definition at line 320 of file TGo4TestRunnable.cxx.

References GO4TRACE, and TGo4Runnable::ThreadCatch().

void TGo4TestRunnable::UnexpectedCatch ( )
protectedvirtual

catch for all unexcpected exceptions happening in workfunc

Reimplemented from TGo4Runnable.

Definition at line 334 of file TGo4TestRunnable.cxx.

References GO4TRACE, and TGo4Runnable::UnexpectedCatch().

Member Data Documentation

Int_t TGo4TestRunnable::fiMode
private

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

Definition at line 106 of file TGo4TestRunnable.h.

Referenced by Run(), and TGo4TestRunnable().

TCanvas* TGo4TestRunnable::fxCanvas
private

Definition at line 110 of file TGo4TestRunnable.h.

TH1D* TGo4TestRunnable::fxHisto
private

Definition at line 111 of file TGo4TestRunnable.h.

Referenced by Run().

TPad* TGo4TestRunnable::fxPad
private

Definition at line 109 of file TGo4TestRunnable.h.


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