GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4LocalCommandRunnable.cxx
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
15
16#include "TGo4ServerTask.h"
17#include "TGo4Command.h"
18#include "TGo4CommandInvoker.h"
19#include "TGo4Thread.h"
20#include "TGo4ObjectQueue.h"
21
27
29 TGo4Runnable(name,task),
30 fxLocalTask(task)
31{
32}
33
37
39{
40 TGo4ObjectQueue *fxQueue = fxLocalTask ? fxLocalTask->GetLocalCommandQueue() : nullptr;
41
42 if(fxQueue) {
43 TGo4Command *com = dynamic_cast<TGo4Command *> (fxQueue->WaitObject());
44 if(com) {
45 if( com->GetCommandID() != TGo4Task::Get_fgiTERMID() ) {
46 // normal operation if we have not a terminate dummy command
47 //TGo4LockGuard mainlock; // protect command invocation!
48 TGo4CommandInvoker::Instance()->Invoke(com); // execute command by invoker
49 } else {
50 // terminate dummy command: do not execute, but stop this thread
51 GetThread()->Stop();
52 }
53 delete com;
54 }
55 }
56 return 0;
57}
static TGo4CommandInvoker * Instance()
virtual void Invoke(TGo4Command *com)
This is the Go4 Abstract Command Class; part of the Base command pattern.
Definition TGo4Command.h:35
Int_t GetCommandID() const
Int_t Run(void *) override
The working function which runs in the thread.
Class containing a pointer queue for objects.
TObject * WaitObject()
Wait for object from queue.
TGo4Runnable(const TGo4Runnable &right)
TGo4Thread * GetThread() const
Go4 Task.
Definition TGo4Task.h:39
static Int_t Get_fgiTERMID()
Definition TGo4Task.cxx:588
Bool_t Stop()
resets running flag for runnable