TGo4Task Class Reference

#include <TGo4Task.h>

Inheritance diagram for TGo4Task:

TGo4ThreadManager TGo4CommandReceiver TGo4ClientTask TGo4ServerTask TGo4ExampleClient TGo4ExampleServer

List of all members.

Public Member Functions

 TGo4Task (const char *name, Bool_t blockingmode, Bool_t autostart=kFALSE, Bool_t autocreate=kTRUE, Bool_t ismaster=kFALSE)
virtual ~TGo4Task ()
virtual void Start ()
 General start method of client application to be called from remote command; should be re-implemented by application.
virtual void Stop ()
 General stop method of client application to be called from remote command; should be re-implemented by application.
virtual void Quit ()
 Quit the client; method to be called from command object, may be overridden in user implementation.
virtual void KillMain ()
 Kill the main thread; method to be called from command, should be overridden in user implementation.
virtual void RestartMain ()
 Restart the main thread; method to be called from command, should be overridden in user implementation.
virtual void Terminate (Bool_t termapp=kTRUE)
 deletes the Manager instance via Control timer.
virtual void TerminateFast ()
 Overwrites the Threadmanager TerminateFast to shutdown the objectserver properly.
virtual void ExecuteString (const char *command)
 Execute string command.
Bool_t IsMaster ()
void SetOwner (TGo4TaskOwner *owner)
 Set owner object and switch automatically in master or slave mode, depending on owner type.
virtual TGo4TaskHandlerGetTaskHandler ()
virtual TGo4BufferQueueGetCommandQueue (const char *task=0)
virtual TGo4BufferQueueGetStatusQueue (const char *task=0)
virtual TGo4BufferQueueGetDataQueue (const char *task=0)
void AddUserCommand (TGo4Command *com)
 Add a user command object to the existing command list.
void AddUserCommandList (TGo4CommandProtoList *comlist)
 Add a user command list to the existing command list.
TGo4StatusNextStatus (Bool_t wait=kTRUE)
 Delivers next status object from status queue.
TObject * NextObject (Bool_t wait=kTRUE)
 Delivers next object from data queue.
virtual TGo4CommandNextCommand ()
 Delivers next command from command queue.
void SendObject (TObject *obj, const char *receiver=0)
 Send object via data channel to the master.
virtual void SendStatus (TGo4Status *stat, const char *receiver=0)
 Send status object via status channel to the master.
virtual void SendStatusBuffer ()
 Send internal status buffer to the master(s).
TMutex * GetStatusBufferMutex ()
 Access to the mutex of status buffer.
void SendStatusMessage (Int_t level, Bool_t printout, const char *text,...)
 Send message string in a status object to the gui.
void UpdateStatusBuffer ()
 Create status object and stream it into the status send buffer.
virtual Int_t Initialization ()
 Overrides the ThreadManager Initialization; is used to setup the client connections on demand; checks for fbConnectRequest flag.
virtual TGo4TaskStatusCreateStatus ()
 create a status object with information on the current (slave) task.
Bool_t SubmitCommand (const char *name)
 send command specified by name to the current client task
Bool_t SubmitEmergencyCommand (Go4EmergencyCommand_t val)
 send emergency quit command to the current client task
Bool_t SubmitEmergencyData (Go4EmergencyCommand_t val, const char *receiver=0)
 Send emergency command via data channel.
Bool_t SubmitLocalCommand (TGo4Command *com)
 Send given command to the current client task.
Bool_t SubmitCommand (TGo4Command *com)
 send given command to the current client task.
TGo4CommandMakeCommand (const char *name)
 Method using internal command prototype list to produce a clone of the specified command.
void WakeCommandQueue (Int_t id=0)
 Put dummy object into command queue to wake up user threads which might wait for a command.
virtual Int_t StartWorkThreads ()
 start the working threads of the task implementation; this method is used after the current connection has changed, to continue reading/writing the queues.
virtual Int_t StopWorkThreads ()
 stop the working threads of the task implementation; this method is used before the current connection is changed to prevent reading/writing and waiting for the wrong queues.
Bool_t IsWorkStopped ()
virtual void LockAll ()
 Lock all go4 mutexes in correct order to avoid deadlocking.
virtual void UnLockAll ()
 UnLock all go4 mutexes in correct order to avoid deadlocking to be used from cintlocktimer.
virtual void GetStatus ()
 Send current status information of the task to the master; may be re-implemented by application subclass of TGo4Task.
const char * GetCommanderName () const
TGo4MasterGetMaster ()
TGo4SlaveGetSlave ()
void SendStopBuffers (const char *taskname=0)
 Send message buffers with stop values into queues and via socket connections.
TBuffer * GetAbortBuffer ()
 Use preallocated abort buffer to stop remote socket wait from taskhandler itself.

Static Public Member Functions

static Int_t Get_fgiTERMID ()

Protected Member Functions

virtual
TGo4TaskHandlerCommandList
CreateCommandList ()
 factory method for command list; overridden by implementation
TGo4TaskHandlerCommandListGetPrototype ()
 get pointer to currently valid command list
virtual void UpdateStatus (TGo4TaskStatus *state)
 method needed by method CreateStatus of any status subclasses to set the values of the clienttask specific part of the status object.
TGo4ObjectQueueGetLocalCommandQueue ()
void SetMaster (Bool_t on=kTRUE)
void SetWorkIsStopped (Bool_t on)

Protected Attributes

TMutex * fxStatusMutex
 Mutex protecting status buffer between main and watch thread.
TBuffer * fxStatusBuffer
 Buffer containing the analysis status which is updated by the main thread.

Private Member Functions

void SetMaster (TGo4Master *m)
void SetSlave (TGo4Slave *s)

Private Attributes

TGo4TaskHandlerCommandListfxCommandPrototype
 the command list which holds all command prototypes
TGo4ObjectQueuefxLocalCommandQueue
 queue for the server side local commands, submitted by the gui or cli
Bool_t fbCommandMaster
 This flag indicates the main state of the task: either master (sends commands, receives data and status), or slave (receives commands and may send date and status).
TString fxCommanderName
 remember name of localcommand thread
TGo4MasterfxMaster
 0.
TGo4SlavefxSlave
 0.
TGo4TaskOwnerfxOwner
 0.
Bool_t fbWorkIsStopped
 True if user work threads are stopped for connection change.
TBuffer * fxStopBuffer
 this buffer is used for stop message for threads
TBuffer * fxQuitBuffer
 this buffer is used for quit command
TBuffer * fxAbortBuffer
 this buffer is used for emergeny socket aborting

Static Private Attributes

static const Int_t fgiTERMID = 999
 Id number of dummy command that wakes the command queue on termination.

Friends

class TGo4LocalCommandRunnable
class TGo4Slave
class TGo4TaskOwner


Detailed Description

Definition at line 36 of file TGo4Task.h.


Constructor & Destructor Documentation

TGo4Task::TGo4Task ( const char *  name,
Bool_t  blockingmode,
Bool_t  autostart = kFALSE,
Bool_t  autocreate = kTRUE,
Bool_t  ismaster = kFALSE 
)

Definition at line 38 of file TGo4Task.cxx.

TGo4Task::~TGo4Task (  )  [virtual]

Definition at line 71 of file TGo4Task.cxx.


Member Function Documentation

void TGo4Task::Start (  )  [virtual]

General start method of client application to be called from remote command; should be re-implemented by application.

Reimplemented in TGo4ExampleClient.

Definition at line 106 of file TGo4Task.cxx.

void TGo4Task::Stop (  )  [virtual]

General stop method of client application to be called from remote command; should be re-implemented by application.

Reimplemented in TGo4ExampleClient.

Definition at line 111 of file TGo4Task.cxx.

void TGo4Task::Quit (  )  [virtual]

Quit the client; method to be called from command object, may be overridden in user implementation.

Reimplemented in TGo4ClientTask, and TGo4ServerTask.

Definition at line 116 of file TGo4Task.cxx.

void TGo4Task::KillMain (  )  [virtual]

Kill the main thread; method to be called from command, should be overridden in user implementation.

Definition at line 121 of file TGo4Task.cxx.

void TGo4Task::RestartMain (  )  [virtual]

Restart the main thread; method to be called from command, should be overridden in user implementation.

Definition at line 126 of file TGo4Task.cxx.

void TGo4Task::Terminate ( Bool_t  termapp = kTRUE  )  [virtual]

deletes the Manager instance via Control timer.

If termap is true, also terminates the root Application

Reimplemented from TGo4ThreadManager.

Definition at line 131 of file TGo4Task.cxx.

void TGo4Task::TerminateFast (  )  [virtual]

Overwrites the Threadmanager TerminateFast to shutdown the objectserver properly.

Reimplemented from TGo4ThreadManager.

Definition at line 139 of file TGo4Task.cxx.

void TGo4Task::ExecuteString ( const char *  command  )  [virtual]

Execute string command.

Uses gInterpreter by default. May be overridden to evaluate go4 command strings in subclass.

Definition at line 147 of file TGo4Task.cxx.

Bool_t TGo4Task::IsMaster (  )  [inline]

Definition at line 94 of file TGo4Task.h.

void TGo4Task::SetOwner ( TGo4TaskOwner owner  ) 

Set owner object and switch automatically in master or slave mode, depending on owner type.

Definition at line 99 of file TGo4Task.cxx.

TGo4TaskHandler * TGo4Task::GetTaskHandler (  )  [virtual]

Reimplemented in TGo4ClientTask, and TGo4ServerTask.

Definition at line 156 of file TGo4Task.cxx.

TGo4BufferQueue * TGo4Task::GetCommandQueue ( const char *  task = 0  )  [virtual]

Reimplemented in TGo4ClientTask, and TGo4ServerTask.

Definition at line 161 of file TGo4Task.cxx.

TGo4BufferQueue * TGo4Task::GetStatusQueue ( const char *  task = 0  )  [virtual]

Reimplemented in TGo4ClientTask, and TGo4ServerTask.

Definition at line 166 of file TGo4Task.cxx.

TGo4BufferQueue * TGo4Task::GetDataQueue ( const char *  task = 0  )  [virtual]

Reimplemented in TGo4ClientTask, and TGo4ServerTask.

Definition at line 170 of file TGo4Task.cxx.

void TGo4Task::AddUserCommand ( TGo4Command com  ) 

Add a user command object to the existing command list.

This can be done on the fly. Command receiver name of user command must match "Analysis", "AnalysisClient", or the name of the user analysis to be executed on the remote side.

Definition at line 238 of file TGo4Task.cxx.

void TGo4Task::AddUserCommandList ( TGo4CommandProtoList comlist  ) 

Add a user command list to the existing command list.

This can be done on the fly. Commands of the user list are added to the existing command list.

Definition at line 243 of file TGo4Task.cxx.

TGo4Status * TGo4Task::NextStatus ( Bool_t  wait = kTRUE  ) 

Delivers next status object from status queue.

Encapsulates the queue wait and the object streaming. Streamer is decoupled from queue wait and sets global lockguard. If wait=kFALSE, queue will be polled once instead of condition wait.

Definition at line 181 of file TGo4Task.cxx.

TObject * TGo4Task::NextObject ( Bool_t  wait = kTRUE  ) 

Delivers next object from data queue.

Encapsulates the queue wait and the object streaming. Streamer is decoupled from queue wait and sets global lockguard. If wait=kFALSE, queue will be polled once instead of condition wait.

Definition at line 219 of file TGo4Task.cxx.

TGo4Command * TGo4Task::NextCommand (  )  [virtual]

Delivers next command from command queue.

Reimplemented in TGo4ServerTask.

Definition at line 362 of file TGo4Task.cxx.

void TGo4Task::SendObject ( TObject *  obj,
const char *  receiver = 0 
)

Send object via data channel to the master.

Master name may be specified, if more than one master is connected. By default, object is send to current active task

Definition at line 254 of file TGo4Task.cxx.

void TGo4Task::SendStatus ( TGo4Status stat,
const char *  receiver = 0 
) [virtual]

Send status object via status channel to the master.

Master name may be specified, if more than one master is connected. By default, object is send to all connected tasks

Reimplemented in TGo4ServerTask.

Definition at line 279 of file TGo4Task.cxx.

void TGo4Task::SendStatusBuffer (  )  [virtual]

Send internal status buffer to the master(s).

Reimplemented in TGo4ServerTask.

Definition at line 296 of file TGo4Task.cxx.

TMutex* TGo4Task::GetStatusBufferMutex (  )  [inline]

Access to the mutex of status buffer.

To be locked outside any command, otherwise deadlocking possible

Definition at line 155 of file TGo4Task.h.

void TGo4Task::SendStatusMessage ( Int_t  level,
Bool_t  printout,
const char *  text,
  ... 
)

Send message string in a status object to the gui.

Will be displayed in status window. Level indicates info, warning or error. Message text may begin with name of receiver for message, followed by "::". If no receiver is defined, all connected masters will receive message (default).

Definition at line 305 of file TGo4Task.cxx.

void TGo4Task::UpdateStatusBuffer (  ) 

Create status object and stream it into the status send buffer.

To be executed from the main thread; buffer will be send by status thread.

Definition at line 344 of file TGo4Task.cxx.

Int_t TGo4Task::Initialization (  )  [virtual]

Overrides the ThreadManager Initialization; is used to setup the client connections on demand; checks for fbConnectRequest flag.

Reimplemented from TGo4ThreadManager.

Reimplemented in TGo4ClientTask.

Definition at line 398 of file TGo4Task.cxx.

TGo4TaskStatus * TGo4Task::CreateStatus (  )  [virtual]

create a status object with information on the current (slave) task.

this object may be sent to the master or may be used to restore current status by memento mechanism

Reimplemented in TGo4ClientTask, and TGo4ExampleClient.

Definition at line 438 of file TGo4Task.cxx.

Bool_t TGo4Task::SubmitCommand ( const char *  name  ) 

send command specified by name to the current client task

Definition at line 446 of file TGo4Task.cxx.

Bool_t TGo4Task::SubmitEmergencyCommand ( Go4EmergencyCommand_t  val  ) 

send emergency quit command to the current client task

Definition at line 474 of file TGo4Task.cxx.

Bool_t TGo4Task::SubmitEmergencyData ( Go4EmergencyCommand_t  val,
const char *  receiver = 0 
)

Send emergency command via data channel.

For analysis server shutdown, to inform clients about disconnect

Definition at line 496 of file TGo4Task.cxx.

Bool_t TGo4Task::SubmitLocalCommand ( TGo4Command com  ) 

Send given command to the current client task.

Command object is deleted after this call internally!

Definition at line 551 of file TGo4Task.cxx.

Bool_t TGo4Task::SubmitCommand ( TGo4Command com  ) 

send given command to the current client task.

Command object is deleted after this call internally!

Definition at line 518 of file TGo4Task.cxx.

TGo4Command * TGo4Task::MakeCommand ( const char *  name  ) 

Method using internal command prototype list to produce a clone of the specified command.

Definition at line 545 of file TGo4Task.cxx.

void TGo4Task::WakeCommandQueue ( Int_t  id = 0  ) 

Put dummy object into command queue to wake up user threads which might wait for a command.

To be used in quit and restart methods. Id can set in such way that application can check the command id for special action, e.g. stop thread in case of termination.

Definition at line 566 of file TGo4Task.cxx.

Int_t TGo4Task::StartWorkThreads (  )  [virtual]

start the working threads of the task implementation; this method is used after the current connection has changed, to continue reading/writing the queues.

To be overridden by the derived task.

Reimplemented in TGo4ExampleServer.

Definition at line 595 of file TGo4Task.cxx.

Int_t TGo4Task::StopWorkThreads (  )  [virtual]

stop the working threads of the task implementation; this method is used before the current connection is changed to prevent reading/writing and waiting for the wrong queues.

To be overridden by the derived task.

Reimplemented in TGo4ExampleServer.

Definition at line 604 of file TGo4Task.cxx.

Bool_t TGo4Task::IsWorkStopped (  )  [inline]

Definition at line 243 of file TGo4Task.h.

void TGo4Task::LockAll (  )  [virtual]

Lock all go4 mutexes in correct order to avoid deadlocking.

to be used from cintlocktimer

Reimplemented in TGo4ServerTask.

Definition at line 648 of file TGo4Task.cxx.

void TGo4Task::UnLockAll (  )  [virtual]

UnLock all go4 mutexes in correct order to avoid deadlocking to be used from cintlocktimer.

Reimplemented in TGo4ServerTask.

Definition at line 655 of file TGo4Task.cxx.

void TGo4Task::GetStatus (  )  [virtual]

Send current status information of the task to the master; may be re-implemented by application subclass of TGo4Task.

Definition at line 582 of file TGo4Task.cxx.

const char* TGo4Task::GetCommanderName (  )  const [inline]

Definition at line 261 of file TGo4Task.h.

TGo4Master* TGo4Task::GetMaster (  )  [inline]

Definition at line 263 of file TGo4Task.h.

TGo4Slave* TGo4Task::GetSlave (  )  [inline]

Definition at line 265 of file TGo4Task.h.

void TGo4Task::SendStopBuffers ( const char *  taskname = 0  ) 

Send message buffers with stop values into queues and via socket connections.

Used in disconnect procedure to put taskhandler threads into suspend mode, i.e. wake them from socket receive or queue wait. For multiple client connection, taskname defines which client to stop.

Definition at line 613 of file TGo4Task.cxx.

TBuffer* TGo4Task::GetAbortBuffer (  )  [inline]

Use preallocated abort buffer to stop remote socket wait from taskhandler itself.

Definition at line 278 of file TGo4Task.h.

Int_t TGo4Task::Get_fgiTERMID (  )  [static]

Definition at line 661 of file TGo4Task.cxx.

TGo4TaskHandlerCommandList * TGo4Task::CreateCommandList (  )  [protected, virtual]

factory method for command list; overridden by implementation

Reimplemented in TGo4ExampleServer.

Definition at line 540 of file TGo4Task.cxx.

TGo4TaskHandlerCommandList * TGo4Task::GetPrototype (  )  [protected]

get pointer to currently valid command list

Definition at line 175 of file TGo4Task.cxx.

void TGo4Task::UpdateStatus ( TGo4TaskStatus state  )  [protected, virtual]

method needed by method CreateStatus of any status subclasses to set the values of the clienttask specific part of the status object.

Reimplemented in TGo4ClientTask.

Definition at line 429 of file TGo4Task.cxx.

TGo4ObjectQueue* TGo4Task::GetLocalCommandQueue (  )  [inline, protected]

Definition at line 298 of file TGo4Task.h.

void TGo4Task::SetMaster ( Bool_t  on = kTRUE  )  [inline, protected]

Definition at line 300 of file TGo4Task.h.

void TGo4Task::SetWorkIsStopped ( Bool_t  on  )  [inline, protected]

Definition at line 302 of file TGo4Task.h.

void TGo4Task::SetMaster ( TGo4Master m  )  [private]

Definition at line 87 of file TGo4Task.cxx.

void TGo4Task::SetSlave ( TGo4Slave s  )  [private]

Definition at line 93 of file TGo4Task.cxx.


Friends And Related Function Documentation

friend class TGo4LocalCommandRunnable [friend]

Definition at line 39 of file TGo4Task.h.

friend class TGo4Slave [friend]

Definition at line 40 of file TGo4Task.h.

friend class TGo4TaskOwner [friend]

Definition at line 41 of file TGo4Task.h.


Member Data Documentation

TMutex* TGo4Task::fxStatusMutex [protected]

Mutex protecting status buffer between main and watch thread.

Definition at line 305 of file TGo4Task.h.

TBuffer* TGo4Task::fxStatusBuffer [protected]

Buffer containing the analysis status which is updated by the main thread.

Definition at line 308 of file TGo4Task.h.

the command list which holds all command prototypes

Definition at line 317 of file TGo4Task.h.

queue for the server side local commands, submitted by the gui or cli

Definition at line 320 of file TGo4Task.h.

Bool_t TGo4Task::fbCommandMaster [private]

This flag indicates the main state of the task: either master (sends commands, receives data and status), or slave (receives commands and may send date and status).

Definition at line 325 of file TGo4Task.h.

TString TGo4Task::fxCommanderName [private]

remember name of localcommand thread

Definition at line 328 of file TGo4Task.h.

0.

.1

Definition at line 331 of file TGo4Task.h.

0.

.1

Definition at line 334 of file TGo4Task.h.

0.

.1

Definition at line 337 of file TGo4Task.h.

Bool_t TGo4Task::fbWorkIsStopped [private]

True if user work threads are stopped for connection change.

Definition at line 340 of file TGo4Task.h.

TBuffer* TGo4Task::fxStopBuffer [private]

this buffer is used for stop message for threads

Definition at line 344 of file TGo4Task.h.

TBuffer* TGo4Task::fxQuitBuffer [private]

this buffer is used for quit command

Definition at line 347 of file TGo4Task.h.

TBuffer* TGo4Task::fxAbortBuffer [private]

this buffer is used for emergeny socket aborting

Definition at line 350 of file TGo4Task.h.

const Int_t TGo4Task::fgiTERMID = 999 [static, private]

Id number of dummy command that wakes the command queue on termination.

Definition at line 353 of file TGo4Task.h.


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

Generated on Thu Oct 28 12:31:33 2010 for Go4-Taskhandlerv4.04-2 by  doxygen 1.5.6