v2.10-0 (21000JUN2005)

Go4TaskHandler
Class TGo4Task

Direct Known Subclasses:
TGo4ClientTask, TGo4ServerTask

class TGo4Task
derived from TGo4CommandReceiver, TGo4ThreadManager


Field Summary
 private Bool_tfbCommandMaster
          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)
 private Bool_tfbWorkIsStopped
          True if user work threads
are stopped for connection change
 const static const Int_tfgiTERMID
          Id number of dummy command that wakes the command queue on termination
 private TStringfxCommanderName
          remember name of localcommand thread
 private TGo4TaskHandlerCommandList*fxCommandPrototype
          the command list which holds all command prototypes
 private TGo4ObjectQueue*fxLocalCommandQueue
          queue for the server side local commands, submitted by the gui or cli
 private TGo4Master*fxMaster
           
 private TGo4TaskOwner*fxOwner
           
 private TBuffer*fxQuitBuffer
          this buffer is used for quit command
 private TGo4Slave*fxSlave
           
 protected TBuffer*fxStatusBuffer
          Buffer containing the analysis status which is
updated by the main thread
 protected TMutex*fxStatusMutex
          Mutex protecting status buffer between main and
watch thread.
 private TBuffer*fxStopBuffer
          this buffer is used for stop message for threads

Fields inherited from class Go4ThreadManager.TGo4ThreadManager
fbAppBlocking, fbAutoCreate, fbAutoStart, fbInitDone, fbTerminateApplication, fbTerminating, fglTIMERPERIOD, fguTEXTLENGTH, fxBlocker, fxWorkHandler

Fields inherited from class TNamed
fName, fTitle

Constructor Summary
TGo4Task(const char * name, Bool_t blockingmode, Bool_t autostart, Bool_t autocreate, Bool_t ismaster)
           

Destructor Summary
 virtual synchronized ~TGo4Task()
           

Method Summary
 voidAddUserCommand(TGo4Command* com)
          Add a user command object to the existing command list.
 voidAddUserCommandList(TGo4CommandProtoList* comlist)
          Add a user command list to the existing command list.
 protected virtual TGo4TaskHandlerCommandList*CreateCommandList()
          factory method for command list; overridden by implementation
 virtual TGo4TaskStatus*CreateStatus()
          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
 virtual voidExecuteString(const Text_t* command)
          Execute string command.
 const const char *GetCommanderName()
           
 virtual TGo4BufferQueue*GetCommandQueue(const char * task)
           
 virtual TGo4BufferQueue*GetDataQueue(const char * task)
           
 protected TGo4ObjectQueue*GetLocalCommandQueue()
           
 TGo4Master*GetMaster()
           
 protected TGo4TaskHandlerCommandList*GetPrototype()
          get pointer to currently valid command list
 TGo4Slave*GetSlave()
           
 virtual voidGetStatus()
          Send current status information of the task to the
master; may be re-implemented by application subclass
of TGo4Task
 virtual TGo4BufferQueue*GetStatusQueue(const char * task)
           
 virtual TGo4TaskHandler*GetTaskHandler()
           
 virtual Int_tInitialization()
          Overrides the ThreadManager Initialization; is used to setup the
client connections on demand; checks for fbConnectRequest flag
 Bool_tIsMaster()
           
 Bool_tIsWorkStopped()
           
 virtual voidKillMain()
          Kill the main thread; method to be called from
command, should be overridden in user
implementation
 TGo4Command*MakeCommand(const char * name)
          Method using internal command prototype list to produce a clone
of the specified command
 virtual TGo4Command*NextCommand()
          Delivers next command from command queue.
 TObject*NextObject(Bool_t wait)
          Delivers next object from data queue.
 TGo4Status*NextStatus(Bool_t wait)
          Delivers next status object from status queue.
 virtual voidQuit()
          Quit the client; method to be called from
command object, may be overridden in user
implementation
 virtual voidRestartMain()
          Restart the main thread; method to be called from
command, should be overridden in user
implementation
 voidSendObject(TObject* obj, const char * receiver)
          Send object via data channel to the master.
 virtual voidSendStatus(TGo4Status* stat, const char * receiver)
          Send status object via status channel to the master.
 virtual voidSendStatusBuffer()
          Send internal status buffer to the master(s).
 voidSendStatusMessage(Int_t level, Bool_t printout, const char * text, ... )
          Send message string in a status object to the gui.
 voidSendStopBuffers(const char * taskname)
          Send message buffers with stop values into queues and
via socket connections.
 protected voidSetMaster(Bool_t on)
           
 private voidSetMaster(TGo4Master* m)
           
 voidSetOwner(TGo4TaskOwner* owner)
          Set owner object and switch automatically in master or slave
mode, depending on owner type
 private voidSetSlave(TGo4Slave* s)
           
 protected voidSetWorkIsStopped(Bool_t on)
           
 virtual voidStart()
          General start method of client application to be called from remote
command; should be re-implemented by application
 virtual Int_tStartWorkThreads()
          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 voidStop()
          General stop method of client application to be called from remote
command; should be re-implemented by application
 virtual Int_tStopWorkThreads()
          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_tSubmitCommand(const char * name)
          send command specified by name to the current client task
 Bool_tSubmitCommand(TGo4Command* com)
          send given command to the current client task.
 Bool_tSubmitEmergencyCommand(Go4EmergencyCommand_t val)
          send emergency quit command to the current client task
 Bool_tSubmitEmergencyData(Go4EmergencyCommand_t val, const char * receiver)
          Send emergency command via data channel.
 Bool_tSubmitLocalCommand(TGo4Command* com)
          send given command to the current client task.
 virtual voidTerminate(Bool_t termapp)
           
 virtual voidTerminateFast()
          Overwrites the Threadmanager TerminateFast to shutdown the objectserver properly
 protected virtual voidUpdateStatus(TGo4TaskStatus* state)
          method needed by method
CreateStatus of any status subclasses to
set the values of the clienttask specific
part of the status object.
 voidUpdateStatusBuffer()
          Create status object and stream it into the
status send buffer.
 voidWakeCommandQueue(Int_t id)
          Put dummy object into command queue
to wake up user threads which might
wait for a command.

Methods inherited from class Go4ThreadManager.TGo4ThreadManager
BlockApp, GetWorkHandler, IsAppBlocking, IsInitDone, IsTerminateApp, IsTerminating, Launch, operator=, SetTimer, UnBlockApp

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

fbCommandMaster

private 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)

fbWorkIsStopped

private Bool_t fbWorkIsStopped
True if user work threads
are stopped for connection change

fgiTERMID

public const static const Int_t fgiTERMID
Id number of dummy command that wakes the command queue on termination

fxCommanderName

private TString fxCommanderName
remember name of localcommand thread

fxCommandPrototype

private TGo4TaskHandlerCommandList* fxCommandPrototype
the command list which holds all command prototypes

fxLocalCommandQueue

private TGo4ObjectQueue* fxLocalCommandQueue
queue for the server side local commands, submitted by the gui or cli

fxMaster

private TGo4Master* fxMaster
supplierCardinality 0..1

fxOwner

private TGo4TaskOwner* fxOwner
supplierCardinality 0..1

fxQuitBuffer

private TBuffer* fxQuitBuffer
this buffer is used for quit command

fxSlave

private TGo4Slave* fxSlave
supplierCardinality 0..1

fxStatusBuffer

protected TBuffer* fxStatusBuffer
Buffer containing the analysis status which is
updated by the main thread

fxStatusMutex

protected TMutex* fxStatusMutex
Mutex protecting status buffer between main and
watch thread.

fxStopBuffer

private TBuffer* fxStopBuffer
this buffer is used for stop message for threads
Constructor Detail

TGo4Task

public TGo4Task(const char * name, Bool_t blockingmode, Bool_t autostart, Bool_t autocreate, Bool_t ismaster)
Method Detail

~TGo4Task

public virtual synchronized ~TGo4Task()
Method Detail

AddUserCommand

public void 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.

AddUserCommandList

public void 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.

CreateCommandList

protected virtual TGo4TaskHandlerCommandList* CreateCommandList()
factory method for command list; overridden by implementation

CreateStatus

public virtual TGo4TaskStatus* CreateStatus()
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

ExecuteString

public virtual void ExecuteString(const Text_t* command)
Execute string command. Uses gInterpreter by default. May be overridden
to evaluate go4 command strings in subclass.

GetCommanderName

public const const char * GetCommanderName()

GetCommandQueue

public virtual TGo4BufferQueue* GetCommandQueue(const char * task)

GetDataQueue

public virtual TGo4BufferQueue* GetDataQueue(const char * task)

GetLocalCommandQueue

protected TGo4ObjectQueue* GetLocalCommandQueue()

GetMaster

public TGo4Master* GetMaster()

GetPrototype

protected TGo4TaskHandlerCommandList* GetPrototype()
get pointer to currently valid command list

GetSlave

public TGo4Slave* GetSlave()

GetStatus

public virtual void GetStatus()
Send current status information of the task to the
master; may be re-implemented by application subclass
of TGo4Task

GetStatusQueue

public virtual TGo4BufferQueue* GetStatusQueue(const char * task)

GetTaskHandler

public virtual TGo4TaskHandler* GetTaskHandler()

Initialization

public virtual Int_t Initialization()
Overrides the ThreadManager Initialization; is used to setup the
client connections on demand; checks for fbConnectRequest flag

IsMaster

public Bool_t IsMaster()

IsWorkStopped

public Bool_t IsWorkStopped()

KillMain

public virtual void KillMain()
Kill the main thread; method to be called from
command, should be overridden in user
implementation

MakeCommand

public TGo4Command* MakeCommand(const char * name)
Method using internal command prototype list to produce a clone
of the specified command

NextCommand

public virtual TGo4Command* NextCommand()
Delivers next command from command queue.

NextObject

public TObject* NextObject(Bool_t wait)
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.

NextStatus

public TGo4Status* NextStatus(Bool_t wait)
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.

Quit

public virtual void Quit()
Quit the client; method to be called from
command object, may be overridden in user
implementation

RestartMain

public virtual void RestartMain()
Restart the main thread; method to be called from
command, should be overridden in user
implementation

SendObject

public void SendObject(TObject* obj, const char * receiver)
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

SendStatus

public virtual void SendStatus(TGo4Status* stat, const char * receiver)
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

SendStatusBuffer

public virtual void SendStatusBuffer()
Send internal status buffer to the master(s).

SendStatusMessage

public void 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).

SendStopBuffers

public void SendStopBuffers(const char * taskname)
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.

SetMaster

protected void SetMaster(Bool_t on)

SetMaster

private void SetMaster(TGo4Master* m)

SetOwner

public void SetOwner(TGo4TaskOwner* owner)
Set owner object and switch automatically in master or slave
mode, depending on owner type

SetSlave

private void SetSlave(TGo4Slave* s)

SetWorkIsStopped

protected void SetWorkIsStopped(Bool_t on)

Start

public virtual void Start()
General start method of client application to be called from remote
command; should be re-implemented by application

StartWorkThreads

public 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. To be overridden by the derived task.

Stop

public virtual void Stop()
General stop method of client application to be called from remote
command; should be re-implemented by application

StopWorkThreads

public 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. To be overridden by the derived task.

SubmitCommand

public Bool_t SubmitCommand(const char * name)
send command specified by name to the current client task

SubmitCommand

public Bool_t SubmitCommand(TGo4Command* com)
send given command to the current client task. Command object is deleted after
this call internally!

SubmitEmergencyCommand

public Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
send emergency quit command to the current client task

SubmitEmergencyData

public Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char * receiver)
Send emergency command via data channel. For analysis server
shutdown, to inform clients about disconnect

SubmitLocalCommand

public Bool_t SubmitLocalCommand(TGo4Command* com)
send given command to the current client task. Command object is deleted after
this call internally!

Terminate

public virtual void Terminate(Bool_t termapp)

TerminateFast

public virtual void TerminateFast()
Overwrites the Threadmanager TerminateFast to shutdown the objectserver properly

UpdateStatus

protected 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.

UpdateStatusBuffer

public void 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.

WakeCommandQueue

public void WakeCommandQueue(Int_t id)
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.

Association Links

to Class TMutex

Mutex protecting status buffer between main and
watch thread.

to Class TBuffer

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

to Class TGo4TaskHandlerCommandList

the command list which holds all command prototypes

to Class TGo4ObjectQueue

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

to Class TGo4Master

Supplier Cardinality 0..1

to Class TGo4Slave

Supplier Cardinality 0..1

to Class TGo4TaskOwner

Supplier Cardinality 0..1

to Class TBuffer

this buffer is used for stop message for threads

to Class TBuffer

this buffer is used for quit command

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

30-06-2005