21#include "TBufferFile.h"
24#include "TGo4LockGuard.h"
64 TString nomen(
"LocalCommandRunnable of "); nomen+=name;
74 fxOwner->SetTask(
nullptr, kFALSE);
149 fxSlave->ExecuteString(command);
151 gROOT->ProcessLineSync(command);
164 TObject *obj =
nullptr;
169 if (!wait && statqueue->
IsEmpty())
173 if (obj->InheritsFrom(TGo4Status::Class())) {
176 TGo4Log::Debug(
" !!! Master Task: NextStatus ERROR, unknown object %s from status queue!!! ",
181 TGo4Log::Debug(
" !!! Master Task NextStatus ERROR -- NULL object from data queue!!! ");
193 TObject *obj =
nullptr;
196 if (!wait && dataqueue->
IsEmpty())
236 TGo4Log::Debug(
" !!! Task - ERROR sending object - no data queue !!! ");
256 TGo4Log::Debug(
" !!! Task - ERROR sending status: no status queue !!! ");
279 va_start(args, text);
280 vsnprintf(txtbuf, lbuflen, text, args);
285 TString receiver = txtbuf;
286 Ssiz_t pos = receiver.Index(
"::",2,0,TString::kExact);
289 receiver.Resize(pos);
290 dest = receiver.Data();
291 curs += ((size_t) pos);
300 if((level > 0) && go4mess) {
313 TFile *filsav = gFile;
329 if(!comq)
return nullptr;
339 if(obj->InheritsFrom(TGo4Command::Class()))
378 TGo4Log::Debug(
" Task -- command list is created from Master factory");
383 TGo4Log::Debug(
" Task -- command list is created from Task factory");
411 if(!strcmp(name,
"THEMQuit"))
415 else if (!strcmp(name,
"THEMKill"))
419 else if (!strcmp(name,
"THEMRestart"))
478 if (!com)
return kFALSE;
510 if(!com)
return kFALSE;
530 com =
new TGo4Command(
"dummy",
"this wakes up queue",
id);
538 TGo4Log::Debug(
" Task ''%s'' Send Status to Command Master ",GetName());
int main(int argc, char **argv)
@ kGo4ComModeAdministrator
Class containing a pointer queue for TBuffers.
static TBuffer * CreateValueBuffer(UInt_t val)
Create a root buffer that contains a single value val.
void AddBuffer(TBuffer *buffer, Bool_t clone=kFALSE)
Add buffer pointer to queue.
void AddBufferFromObject(TObject *object)
Reconstruct a TObject queue entry from a given TBuffer pointer.
TObject * WaitObjectFromBuffer()
Wait for buffer object from queue.
static TGo4CommandInvoker * Instance()
static void SetCommandList(TGo4CommandProtoList *list)
Application may exchange standard command list by own subclass with specialized commands,...
static void UnRegister(TGo4CommandReceiver *p)
static void Register(const char *name, TGo4CommandReceiver *p)
This is the Go4 Abstract Command Class; part of the Base command pattern.
void SetMode(Go4CommandMode_t m)
void SetTaskName(const char *)
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Display a message.
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
static void OutputEnable(Bool_t on=kTRUE)
switch output on or off
static Bool_t IsOutputEnabled()
get current output state
Class containing a pointer queue for objects.
void AddObject(TObject *object, Bool_t clone=kFALSE)
Add object pointer to queue.
This command is a container for commands to be send from master to slave via inter-process transport.
Class containing all command prototypes of the TaskHandler system commands (and the basic test comman...
This class is responsible for the interconnection of two tasks: provided are three communication chan...
virtual TGo4TaskHandlerStatus * CreateStatus()
create a status object with information on the current taskhandler state.
Bool_t IsAborting() const
Check whether this instance is currently being aborted.
void SetTaskHandlerStatus(TGo4TaskHandlerStatus *thstate)
void SetFlags(Bool_t blocking, Bool_t autocreate, Bool_t autostart, Bool_t terminating, Bool_t initdone)
Int_t Initialization() override
Overrides the ThreadManager Initialization; is used to setup the client connections on demand; checks...
virtual Int_t StopWorkThreads()
stop the working threads of the task implementation; this method is used before the current connectio...
TGo4TaskHandlerCommandList * fxCommandPrototype
the command list which holds all command prototypes
TBuffer * fxQuitBuffer
this buffer is used for quit command
TString fxCommanderName
remember name of localcommand thread
static Int_t Get_fgiTERMID()
virtual TGo4Command * NextCommand()
Delivers next command from command queue.
TGo4Task(const char *name, Bool_t blockingmode, Bool_t autostart=kFALSE, Bool_t autocreate=kTRUE, Bool_t ismaster=kFALSE)
virtual void GetStatus()
Send current status information of the task to the master; may be re-implemented by application subcl...
Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
send emergency quit command to the current client task
void SetMaster(Bool_t on=kTRUE)
static const Int_t fgiTERMID
Id number of dummy command that wakes the command queue on termination.
TGo4ObjectQueue * GetLocalCommandQueue()
void SendStopBuffers(const char *taskname=nullptr)
Send message buffers with stop values into queues and via socket connections.
void Terminate(Bool_t termapp=kTRUE) override
deletes the Manager instance via Control timer.
void AddUserCommandList(TGo4CommandProtoList *comlist)
Add a user command list to the existing command list.
Bool_t SubmitCommand(const char *name)
send command specified by name to the current client task
void SetOwner(TGo4TaskOwner *owner)
Set owner object and switch automatically in master or slave mode, depending on owner type.
virtual void SendStatus(TGo4Status *stat, const char *receiver=nullptr)
Send status object via status channel to the master.
virtual TGo4BufferQueue * GetDataQueue(const char *task=nullptr)
TBuffer * fxStopBuffer
this buffer is used for stop message for threads
const char * GetCommanderName() const
virtual void Stop()
General stop method of client application to be called from remote command; should be re-implemented ...
virtual TGo4TaskHandlerCommandList * CreateCommandList()
factory method for command list; overridden by implementation
virtual void SendStatusBuffer()
Send internal status buffer to the master(s).
virtual void Quit()
Quit the client; method to be called from command object, may be overridden in user implementation.
TGo4Command * MakeCommand(const char *name)
Method using internal command prototype list to produce a clone of the specified command.
friend class TGo4TaskOwner
void SetSlave(TGo4Slave *s)
Bool_t SubmitLocalCommand(TGo4Command *com)
Send given command to the current client task.
void SendStatusMessage(Int_t level, Bool_t printout, const char *text,...)
Send message string in a status object to the gui.
virtual TGo4BufferQueue * GetStatusQueue(const char *task=nullptr)
TBuffer * fxStatusBuffer
Buffer containing the analysis status which is updated by the main thread.
TBuffer * fxAbortBuffer
this buffer is used for emergency socket aborting
TGo4Status * NextStatus(Bool_t wait=kTRUE)
Delivers next status object from status queue.
virtual void Start()
General start method of client application to be called from remote command; should be re-implemented...
void AddUserCommand(TGo4Command *com)
Add a user command object to the existing command list.
virtual void UpdateStatus(TGo4TaskStatus *state)
method needed by method CreateStatus of any status subclasses to set the values of the clienttask spe...
friend class TGo4LocalCommandRunnable
virtual void RestartMain()
Restart the main thread; method to be called from command, should be overridden in user implementatio...
TGo4TaskOwner * fxOwner
0..1
void SendObject(TObject *obj, const char *receiver=nullptr)
Send object via data channel to the master.
Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char *receiver=nullptr)
Send emergency command via data channel.
Bool_t fbWorkIsStopped
True if user work threads are stopped for connection change.
virtual void ExecuteString(const char *command)
Execute string command.
Bool_t fbCommandMaster
This flag indicates the main state of the task: either master (sends commands, receives data and stat...
TGo4TaskHandlerCommandList * GetPrototype()
get pointer to currently valid command list
virtual TGo4TaskHandler * GetTaskHandler()
void TerminateFast() override
Overwrites the Threadmanager TerminateFast to shutdown the objectserver properly.
virtual void KillMain()
Kill the main thread; method to be called from command, should be overridden in user implementation.
void UpdateStatusBuffer()
Create status object and stream it into the status send buffer.
virtual Int_t StartWorkThreads()
start the working threads of the task implementation; this method is used after the current connectio...
TMutex * fxStatusMutex
Mutex protecting status buffer between main and watch thread.
TGo4Master * fxMaster
0..1
TObject * NextObject(Bool_t wait=kTRUE)
Delivers next object from data queue.
virtual TGo4TaskStatus * CreateStatus()
create a status object with information on the current (slave) task.
virtual TGo4BufferQueue * GetCommandQueue(const char *task=nullptr)
void WakeCommandQueue(Int_t id=0)
Put dummy object into command queue to wake up user threads which might wait for a command.
TGo4ObjectQueue * fxLocalCommandQueue
queue for the server side local commands, submitted by the gui or cli
Bool_t NewThread(const char *name, TGo4Runnable *runnable)
Creates new internal Go4 Thread with name and adds it to the List External runnable is passed to spec...
TGo4ThreadHandler * fxWorkHandler
Thread handler aggregate (threadsafe list of go4 threads) aggregationByValue 1 1.
Bool_t fbAutoStart
If true, workfunctions (runnable Run()) of all go4threads in list shall be started automatically on I...
virtual void TerminateFast()
Alternative termination in case of error.
Bool_t fbTerminating
flag showing termination status
Bool_t fbInitDone
is set kTRUE after first Initialize is done
virtual Int_t Initialization()
TGo4ThreadHandler * GetWorkHandler() const
Access to ThreadHandler for working threads.
Bool_t fbAutoCreate
If true, TThreads of all go4threads in list shall be created automatically on calling Launch().
Bool_t fbAppBlocking
true if threadmanager shall block root gSystem using the AppControlTimer; false if gSystem shall neve...
TGo4ThreadManager(const TGo4ThreadManager &right)
virtual void Terminate(Bool_t termap=kTRUE)
deletes the Manager instance via Control timer.