00001 // $Id: TGo4LocalCommandRunnable.cxx 1037 2013-11-06 13:39:24Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #include "TGo4LocalCommandRunnable.h" 00015 00016 #include "TGo4Log.h" 00017 #include "TGo4ServerTask.h" 00018 #include "TGo4Command.h" 00019 #include "TGo4CommandInvoker.h" 00020 #include "TGo4Thread.h" 00021 #include "TGo4ObjectQueue.h" 00022 00023 TGo4LocalCommandRunnable::TGo4LocalCommandRunnable() : 00024 TGo4Runnable(), 00025 fxLocalTask(0) 00026 { 00027 } 00028 00029 TGo4LocalCommandRunnable::TGo4LocalCommandRunnable(const char* name, TGo4Task* task) : 00030 TGo4Runnable(name,task), 00031 fxLocalTask(task) 00032 { 00033 } 00034 00035 TGo4LocalCommandRunnable::~TGo4LocalCommandRunnable() 00036 { 00037 } 00038 00039 Int_t TGo4LocalCommandRunnable::Run(void* ptr) 00040 { 00041 TGo4ObjectQueue* fxQueue = fxLocalTask ? fxLocalTask->GetLocalCommandQueue() : 0; 00042 00043 if(fxQueue!=0) { 00044 TGo4Command* com = dynamic_cast<TGo4Command*> (fxQueue->WaitObject()); 00045 if(com!=0) { 00046 if( com->GetCommandID() != TGo4Task::Get_fgiTERMID() ) { 00047 // normal operation if we have not a terminate dummy command 00048 //TGo4LockGuard mainlock; // protect command invocation! 00049 TGo4CommandInvoker::Instance()->Invoke(com); // execute command by invoker 00050 } else { 00051 // terminate dummy command: do not execute, but stop this thread 00052 GetThread()->Stop(); 00053 } 00054 delete com; 00055 } 00056 } 00057 return 0; 00058 }