Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4TaskHandler/TGo4StatusRunnable.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4StatusRunnable.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "Go4Log/TGo4Log.h"
00021 #include "Go4ThreadManager/TGo4ThreadManager.h"
00022 #include "Go4Queue/TGo4BufferQueue.h"
00023 #include "Go4Socket/TGo4Socket.h"
00024 #include "Go4Socket/TGo4SocketSignalHandler.h"
00025 #include "TGo4TaskHandler.h"
00026 #include "TGo4TaskHandlerAbortException.h"
00027 
00028 TGo4StatusRunnable::TGo4StatusRunnable(const char* name, TGo4ThreadManager* man, TGo4TaskHandler* hand, Bool_t receivermode)
00029    :TGo4TaskHandlerRunnable(name,man,hand,receivermode)
00030 {
00031    fxBufferQueue=dynamic_cast<TGo4BufferQueue*> (fxTaskHandler->GetStatusQueue() );
00032    fxTransport=fxTaskHandler->GetStatusTransport();
00033 }
00034 
00035 
00036 TGo4StatusRunnable::~TGo4StatusRunnable()
00037 {
00038 }
00039 
00040 Int_t TGo4StatusRunnable::Run(void* ptr)
00041 {
00042    if(!CheckTransportOpen()) return 0;
00043    if(fbReceiverMode)
00044       {
00045       // server side: receive status objects from client
00046       Int_t  rev = fxTransport->ReceiveBuffer();
00047       if(rev>=0)
00048          {
00049             TBuffer* buf=const_cast<TBuffer*> (fxTransport->GetBuffer());
00050             if(CheckStopBuffer(buf)) return 0; // stop for disconnect mode
00051             fxBufferQueue->AddBuffer(buf, kTRUE);
00052          } 
00053       else
00054          {
00055             if (TGo4SocketSignalHandler::fgiLastSignal == SIGWINCH)
00056                {
00057                   // TSocket error because of window resize, do not abort!
00058                   TGo4Log::Debug(" %s: caught SIGWINCH ",GetName());
00059                   TGo4SocketSignalHandler::fgiLastSignal = 0; // reset
00060                }
00061             else if(fxManager->IsTerminating())
00062                {
00063                   //cout <<"Receive error in "<<GetName()<< " while threadmanager is terminating. Ignored!" << endl;
00064                   TGo4Log::Debug("Receive Error in %s during threadmanager termination. Ignored.",GetName());
00065                   GetThread()->Stop();                  
00066                }     
00067             else
00068                {
00069                   TGo4Log::Debug(" !!!Receive Error in StatusRunnable of Task %s!!!",
00070                         fxTaskHandler->GetName());
00071                    //GetThread()->Stop(); cout <<"Stopped status runnable. no termination" << endl;
00072                   throw TGo4TaskHandlerAbortException(this);
00073                }
00074          }
00075 
00076    } 
00077    else
00078       {
00079       // client side: send status buffer to server
00080          // get next status buffer from queue or wait for it
00081          TBuffer* buf= fxBufferQueue->WaitBuffer();
00082          if (buf)
00083             // check if there is really an object from queue
00084             {
00085                CheckStopBuffer(buf);
00086                fxTransport->SendBuffer(buf);
00087                fxBufferQueue->FreeBuffer(buf); 
00088             }
00089       } // else if(fbReceiverMode)
00090 
00091 
00092 return 0;
00093 }
00094 
00095 
00096 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:06 2005 for Go4-v2.10-5 by doxygen1.2.15