GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4TaskHandlerRunnable.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 "TGo4Log.h"
17 #include "TGo4Socket.h"
18 #include "TGo4BufferQueue.h"
19 #include "TGo4TaskHandler.h"
21 
22 #include "TGo4Thread.h"
23 #include "Go4EmergencyCommands.h"
24 
25 TGo4TaskHandlerRunnable::TGo4TaskHandlerRunnable(const char *name, TGo4ThreadManager *man, TGo4TaskHandler *hand, Bool_t receivermode)
26  :TGo4Runnable(name,man), fxTransport(nullptr), fbReceiverMode(0)
27 {
28  fxTaskHandler = hand;
29  fbReceiverMode = receivermode;
30 }
31 
33 {
34 }
35 
37 {
38  return fxTaskHandler;
39 }
40 
41 Bool_t TGo4TaskHandlerRunnable::CheckStopBuffer(TBuffer *buf, Int_t *result)
42 {
43  if (!buf)
44  return kFALSE;
45  Int_t val = TGo4BufferQueue::DecodeValueBuffer(buf);
46  if (result)
47  *result = val;
48  if (val < 0)
49  return kFALSE; // no valid message in buffer
51  if (comvalue == kComCloseInput) {
52  GetThread()->Stop();
53  return kTRUE;
54  } else if (comvalue == kComAbortTask) {
55  TGo4Log::Debug(" !!!Receiving taskhandler abort buffer in %s !!!", GetName());
57 
58  } else {
59  return kFALSE;
60  }
61 }
62 
64 {
65  Bool_t open = kTRUE;
66  if (!fxTransport)
67  open = kFALSE;
68  else if (!fxTransport->IsOpen())
69  open = kFALSE;
70  else
71  open = kTRUE;
72  if (!open)
74  // avoid wild looping in Run() when socket is not open
75  return open;
76 }
TGo4Thread * GetThread() const
Definition: TGo4Runnable.h:44
Go4EmergencyCommand_t
static UInt_t Get_fguPORTWAITTIME()
Bool_t IsOpen() const
Definition: TGo4Socket.h:37
Bool_t CheckStopBuffer(TBuffer *buf, Int_t *result=nullptr)
Bool_t Stop()
Definition: TGo4Thread.cxx:287
static void Sleep(UInt_t millisecs)
Definition: TGo4Thread.cxx:295
static void Debug(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:281
TGo4TaskHandler * GetTaskHandler()
static Int_t DecodeValueBuffer(TBuffer *buf)