00001 // $Id: TGo4LocalCommandRunnable.cxx 478 2009-10-29 12:26:09Z 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 "Riostream.h" 00017 00018 #include "TGo4Log.h" 00019 #include "TGo4ServerTask.h" 00020 #include "TGo4Command.h" 00021 #include "TGo4CommandInvoker.h" 00022 #include "TGo4Thread.h" 00023 #include "TGo4ObjectQueue.h" 00024 00025 TGo4LocalCommandRunnable::TGo4LocalCommandRunnable() : 00026 TGo4Runnable(), 00027 fxLocalTask(0) 00028 { 00029 } 00030 00031 TGo4LocalCommandRunnable::TGo4LocalCommandRunnable(const char* name, TGo4Task* task) : 00032 TGo4Runnable(name,task), 00033 fxLocalTask(task) 00034 { 00035 TGo4ObjectQueue* fxQueue = 0; 00036 if (fxLocalTask!=0) 00037 fxQueue = fxLocalTask->GetLocalCommandQueue(); 00038 } 00039 00040 TGo4LocalCommandRunnable::~TGo4LocalCommandRunnable() 00041 { 00042 } 00043 00044 Int_t TGo4LocalCommandRunnable::Run(void* ptr) 00045 { 00046 TGo4ObjectQueue* fxQueue = 0; 00047 if (fxLocalTask!=0) 00048 fxQueue = fxLocalTask->GetLocalCommandQueue(); 00049 if(fxQueue!=0) { 00050 TGo4Command* com= dynamic_cast<TGo4Command*> (fxQueue->WaitObject()); 00051 if(com!=0) { 00052 if( com->GetCommandID() != TGo4Task::Get_fgiTERMID() ) { 00053 // normal operation if we have not a terminate dummy command 00054 //TGo4LockGuard mainlock; // protect command invocation! 00055 TGo4CommandInvoker::Instance()->Invoke(com); // execute command by invoker 00056 } else { 00057 // terminate dummy command: do not execute, but stop this thread 00058 GetThread()->Stop(); 00059 } 00060 delete com; 00061 } 00062 } 00063 return 0; 00064 }