GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
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 
23  TGo4Runnable(),
24  fxLocalTask(nullptr)
25 {
26 }
27 
29  TGo4Runnable(name,task),
30  fxLocalTask(task)
31 {
32 }
33 
35 {
36 }
37 
39 {
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 }
TGo4Thread * GetThread() const
Definition: TGo4Runnable.h:44
Bool_t Stop()
Definition: TGo4Thread.cxx:287
TGo4ObjectQueue * GetLocalCommandQueue()
Definition: TGo4Task.h:292
Int_t GetCommandID() const
Definition: TGo4Command.cxx:64
static TGo4CommandInvoker * Instance()
TObject * WaitObject()
virtual void Invoke(TGo4Command *com)
static Int_t Get_fgiTERMID()
Definition: TGo4Task.cxx:588