Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4ThreadManager Class Reference

Base class for classes that shall be accessed from a thread /runnable instance. More...

#include <TGo4ThreadManager.h>

Inheritance diagram for TGo4ThreadManager:

TGo4Task TGo4TestThreadManager TGo4ClientTask TGo4ServerTask TGo4ExampleClient TGo4ExampleServer List of all members.

Public Types

enum  { fguTEXTLENGTH = 256 }
 Default textlength for char arrays. More...

Public Member Functions

 TGo4ThreadManager (const TGo4ThreadManager &right)
 TGo4ThreadManager (const char *name, Bool_t blockingmode=kTRUE, Bool_t autostart=kTRUE, Bool_t autocreate=kTRUE)
 ctor parameters: blockingmode=true: gApplication is blocked by timer autostart=true: all thread runnables start their work on Initialization() autocreate=true: all threads added to handler in threadmanager ctor are created on Launch()
virtual ~TGo4ThreadManager ()
void SetTimer (TGo4AppControlTimer *ctrltimer)
 user can exchange the standard control timer by an own derived one by this method
TGo4ThreadHandlerGetWorkHandler () const
 Access to ThreadHandler for working threads.
Bool_t BlockApp ()
 Blocks gSystem by means of the blocking timer.
Bool_t UnBlockApp (Int_t mode=0)
 Wakes up the control timer waiting for his condition; parameter mode specifies whether timer will block again at next turn (mode=0), timer will block when all threads are up (mode=1), or timer will not block again unless the next Block call, i.e.
virtual Int_t Initialization ()
Bool_t IsInitDone () const
Bool_t IsTerminating () const
 returns termination status of Threadmanager
Bool_t IsTerminateApp () const
Bool_t IsAppBlocking () const
 Returns true if threadmanager works in root system blocking mode.
void Launch ()
 This Method has to be called to create the startup threads and to turn on the application control timer.
virtual void Terminate (Bool_t termapp=kTRUE)
 deletes the Manager instance via Control timer.
virtual void TerminateFast ()
 Alternative termination in case of error.

Static Public Attributes

static const Long_t fglTIMERPERIOD = 200
 Period in ms for the application control timer.

Protected Attributes

Bool_t fbInitDone
 is set kTRUE after first Initialize is done
Bool_t fbTerminating
 flag showing termination status
Bool_t fbTerminateApplication
 If true, terminate complete application.
Bool_t fbAppBlocking
 true if threadmanager shall block root gSystem using the AppControlTimer; false if gSystem shall never be blocked (necessary for gui)
Bool_t fbAutoCreate
 If true, TThreads of all go4threads in list shall be created automatically on calling Launch().
Bool_t fbAutoStart
 If true, workfunctions (runnable Run()) of all go4threads in list shall be started automatically on Initialization.
TGo4AppControlTimerfxBlocker
 Composition of Application control timer.
TGo4ThreadHandlerfxWorkHandler
 Thread handler aggregate (threadsafe list of go4 threads) 1 1.

Private Member Functions

 TGo4ThreadManager ()

Detailed Description

Base class for classes that shall be accessed from a thread /runnable instance.

Author:
J. Adamczewski

Go4 project-DVEE-GSI Darmstadt

Germany

j.adamczewski@gsi.de

Version:
0.9
Since:
jul 2000-oct 2001

Definition at line 33 of file TGo4ThreadManager.h.


Member Enumeration Documentation

anonymous enum
 

Default textlength for char arrays.

Enumeration values:
fguTEXTLENGTH 

Definition at line 95 of file TGo4ThreadManager.h.


Constructor & Destructor Documentation

TGo4ThreadManager::TGo4ThreadManager const TGo4ThreadManager right  ) 
 

Definition at line 31 of file TGo4ThreadManager.cxx.

References fxBlocker, fxWorkHandler, and TRACE.

TGo4ThreadManager::TGo4ThreadManager const char *  name,
Bool_t  blockingmode = kTRUE,
Bool_t  autostart = kTRUE,
Bool_t  autocreate = kTRUE
 

ctor parameters: blockingmode=true: gApplication is blocked by timer autostart=true: all thread runnables start their work on Initialization() autocreate=true: all threads added to handler in threadmanager ctor are created on Launch()

Definition at line 42 of file TGo4ThreadManager.cxx.

References TGo4Log::Debug(), fbAppBlocking, fbAutoCreate, fbAutoStart, fglTIMERPERIOD, fxBlocker, fxWorkHandler, TGo4AppControlTimer::SetApplicationRun(), and TRACE.

TGo4ThreadManager::~TGo4ThreadManager  )  [virtual]
 

Definition at line 77 of file TGo4ThreadManager.cxx.

References fxWorkHandler, and TRACE.

TGo4ThreadManager::TGo4ThreadManager  )  [private]
 


Member Function Documentation

void TGo4ThreadManager::SetTimer TGo4AppControlTimer ctrltimer  )  [inline]
 

user can exchange the standard control timer by an own derived one by this method

Definition at line 48 of file TGo4ThreadManager.h.

References fxBlocker.

TGo4ThreadHandler* TGo4ThreadManager::GetWorkHandler  )  const [inline]
 

Access to ThreadHandler for working threads.

Definition at line 51 of file TGo4ThreadManager.h.

References fxWorkHandler.

Referenced by TGo4ServerTask::ConnectorThreadIsStopped(), TGo4AppControlTimer::Notify(), TGo4TestRunnable::Run(), TGo4ServerTask::StartConnectorThread(), TGo4ExampleServer::StartWorkThreads(), TGo4ServerTask::StopConnectorThread(), TGo4ExampleServer::StopWorkThreads(), TGo4Task::TGo4Task(), TGo4TaskHandler::TGo4TaskHandler(), TGo4ThreadException::TGo4ThreadException(), and TGo4ServerTask::~TGo4ServerTask().

Bool_t TGo4ThreadManager::BlockApp  ) 
 

Blocks gSystem by means of the blocking timer.

Definition at line 85 of file TGo4ThreadManager.cxx.

References fbAppBlocking, fbTerminating, fxBlocker, fxWorkHandler, TGo4ThreadHandler::IsOperating(), TGo4AppControlTimer::SetApplicationRun(), and TRACE.

Referenced by TGo4ThreadHandler::Cancel(), TGo4ThreadHandler::Create(), TGo4ThreadHandler::CreateAll(), Initialization(), TGo4ThreadHandler::ReCreate(), TGo4ThreadHandler::RemoveThread(), TGo4TestRunnable::Run(), TGo4ThreadHandler::Start(), and TGo4ThreadHandler::StartAll().

Bool_t TGo4ThreadManager::UnBlockApp Int_t  mode = 0  ) 
 

Wakes up the control timer waiting for his condition; parameter mode specifies whether timer will block again at next turn (mode=0), timer will block when all threads are up (mode=1), or timer will not block again unless the next Block call, i.e.

applicationrun flag is reset (mode=2)

Definition at line 113 of file TGo4ThreadManager.cxx.

References fxBlocker, TGo4AppControlTimer::GetApplicationRun(), TGo4AppControlTimer::GetCondition(), TGo4AppControlTimer::SetApplicationRun(), and TRACE.

Referenced by TGo4ThreadHandler::Cancel(), TGo4ThreadHandler::Create(), TGo4ThreadHandler::CreateAll(), TGo4ThreadHandler::ReCreate(), TGo4ThreadHandler::RemoveThread(), TGo4TestRunnable::Run(), TGo4ThreadHandler::Start(), TGo4ThreadHandler::StartAll(), and Terminate().

Int_t TGo4ThreadManager::Initialization  )  [virtual]
 

Reimplemented in TGo4ClientTask, and TGo4Task.

Definition at line 161 of file TGo4ThreadManager.cxx.

References TGo4ThreadHandler::AllCreated(), BlockApp(), TGo4Log::Debug(), TGo4ThreadHandler::DumpThreads(), fbAutoCreate, fbAutoStart, fbInitDone, fxWorkHandler, TGo4ThreadHandler::StartAll(), and TRACE.

Referenced by TGo4Task::Initialization(), and TGo4AppControlTimer::Notify().

Bool_t TGo4ThreadManager::IsInitDone  )  const [inline]
 

Definition at line 66 of file TGo4ThreadManager.h.

References fbInitDone.

Bool_t TGo4ThreadManager::IsTerminating  )  const [inline]
 

returns termination status of Threadmanager

Definition at line 69 of file TGo4ThreadManager.h.

References fbTerminating.

Referenced by TGo4HistogramServer::ConnectObjectClient(), TGo4AppControlTimer::Notify(), TGo4StatusRunnable::Run(), TGo4DataRunnable::Run(), TGo4CommandRunnable::Run(), TGo4TaskManager::ServeClient(), TGo4TaskManager::WaitForClientRemoved(), TGo4ServerTask::WaitForConnection(), TGo4HistogramServer::WaitForConnection(), TGo4HistogramServer::WaitForOpen(), and TGo4TaskHandler::WaitGetPort().

Bool_t TGo4ThreadManager::IsTerminateApp  )  const [inline]
 

Definition at line 71 of file TGo4ThreadManager.h.

References fbTerminateApplication.

Referenced by TGo4AppControlTimer::Notify().

Bool_t TGo4ThreadManager::IsAppBlocking  )  const [inline]
 

Returns true if threadmanager works in root system blocking mode.

Definition at line 74 of file TGo4ThreadManager.h.

References fbAppBlocking.

void TGo4ThreadManager::Launch  ) 
 

This Method has to be called to create the startup threads and to turn on the application control timer.

Usually this is done at the end of the user's threadmanager constructor. The idea is that no thread should be started unless the user initializations are done; therefore, its up to the user to define when to Launch.

Definition at line 219 of file TGo4ThreadManager.cxx.

References TGo4ThreadHandler::CreateAll(), fbAutoCreate, fxBlocker, fxWorkHandler, and TRACE.

Referenced by TGo4ClientTask::TGo4ClientTask(), TGo4ExampleClient::TGo4ExampleClient(), TGo4ExampleServer::TGo4ExampleServer(), TGo4ServerTask::TGo4ServerTask(), and TGo4TestThreadManager::TGo4TestThreadManager().

void TGo4ThreadManager::Terminate Bool_t  termapp = kTRUE  )  [virtual]
 

deletes the Manager instance via Control timer.

If termap is true, also terminates the root Application

Reimplemented in TGo4Task.

Definition at line 236 of file TGo4ThreadManager.cxx.

References TGo4Log::Debug(), fbTerminateApplication, fbTerminating, fxWorkHandler, TGo4ThreadHandler::StopAll(), TRACE, and UnBlockApp().

Referenced by TGo4TerminateException::Handle(), TGo4Task::Terminate(), TerminateFast(), and TGo4Runnable::UnexpectedCatch().

void TGo4ThreadManager::TerminateFast  )  [virtual]
 

Alternative termination in case of error.

Reimplemented in TGo4Task.

Definition at line 250 of file TGo4ThreadManager.cxx.

References Terminate().

Referenced by TGo4Task::TerminateFast().


Member Data Documentation

const Long_t TGo4ThreadManager::fglTIMERPERIOD = 200 [static]
 

Period in ms for the application control timer.

Definition at line 29 of file TGo4ThreadManager.cxx.

Referenced by TGo4ThreadManager().

Bool_t TGo4ThreadManager::fbInitDone [protected]
 

is set kTRUE after first Initialize is done

Definition at line 100 of file TGo4ThreadManager.h.

Referenced by Initialization(), TGo4Task::Initialization(), TGo4ClientTask::Initialization(), IsInitDone(), and TGo4Task::UpdateStatus().

Bool_t TGo4ThreadManager::fbTerminating [protected]
 

flag showing termination status

Definition at line 103 of file TGo4ThreadManager.h.

Referenced by BlockApp(), IsTerminating(), Terminate(), and TGo4Task::UpdateStatus().

Bool_t TGo4ThreadManager::fbTerminateApplication [protected]
 

If true, terminate complete application.

If false, only terminate threadmanager instance.

Definition at line 107 of file TGo4ThreadManager.h.

Referenced by IsTerminateApp(), and Terminate().

Bool_t TGo4ThreadManager::fbAppBlocking [protected]
 

true if threadmanager shall block root gSystem using the AppControlTimer; false if gSystem shall never be blocked (necessary for gui)

Definition at line 112 of file TGo4ThreadManager.h.

Referenced by BlockApp(), IsAppBlocking(), TGo4ThreadManager(), and TGo4Task::UpdateStatus().

Bool_t TGo4ThreadManager::fbAutoCreate [protected]
 

If true, TThreads of all go4threads in list shall be created automatically on calling Launch().

Definition at line 116 of file TGo4ThreadManager.h.

Referenced by Initialization(), Launch(), TGo4ThreadManager(), and TGo4Task::UpdateStatus().

Bool_t TGo4ThreadManager::fbAutoStart [protected]
 

If true, workfunctions (runnable Run()) of all go4threads in list shall be started automatically on Initialization.

If false, TThreads may be running, but workfunctions suspend in condition wait.

Definition at line 121 of file TGo4ThreadManager.h.

Referenced by Initialization(), TGo4ThreadManager(), and TGo4Task::UpdateStatus().

TGo4AppControlTimer* TGo4ThreadManager::fxBlocker [protected]
 

Composition of Application control timer.

1 1

Definition at line 127 of file TGo4ThreadManager.h.

Referenced by BlockApp(), Launch(), SetTimer(), TGo4ThreadManager(), and UnBlockApp().

TGo4ThreadHandler* TGo4ThreadManager::fxWorkHandler [protected]
 

Thread handler aggregate (threadsafe list of go4 threads) 1 1.

Definition at line 133 of file TGo4ThreadManager.h.

Referenced by BlockApp(), TGo4ClientTask::ConnectServer(), GetWorkHandler(), Initialization(), TGo4Task::Initialization(), Launch(), TGo4ExampleClient::Start(), TGo4ExampleClient::Stop(), TGo4Task::SubmitLocalCommand(), Terminate(), TGo4ExampleClient::TGo4ExampleClient(), TGo4ExampleServer::TGo4ExampleServer(), TGo4ServerTask::TGo4ServerTask(), TGo4TestThreadManager::TGo4TestThreadManager(), TGo4ThreadManager(), TGo4ExampleClient::~TGo4ExampleClient(), TGo4ExampleServer::~TGo4ExampleServer(), and ~TGo4ThreadManager().


The documentation for this class was generated from the following files:
Generated on Fri Nov 28 13:01:22 2008 for Go4-v3.04-1 by  doxygen 1.4.2