ROOT  6.06/09
Reference Guide
TXSocketHandler.cxx
Go to the documentation of this file.
1 // @(#)root/proofx:$Id$
2 // Author: Gerardo Ganis 12/12/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TXSocketHandler //
15 // //
16 // Input handler for xproofd sockets. These sockets cannot be directly //
17 // monitored on their descriptor, because the reading activity goes via //
18 // the reader thread. This class allows to handle this problem. //
19 // //
20 //////////////////////////////////////////////////////////////////////////
21 
22 #include "TMonitor.h"
23 #include "TProof.h"
24 #include "TSlave.h"
25 #include "TXSocketHandler.h"
26 #include "TXHandler.h"
27 #include "TList.h"
28 
29 
31 
32 // Unique instance of the socket input handler
33 TXSocketHandler *TXSocketHandler::fgSocketHandler = 0;
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// Set readiness on the monitor
37 
38 Bool_t TXSocketHandler::Notify()
39 {
40  if (gDebug > 2)
42 
43  // Get the socket
45  if (gDebug > 2)
46  Info("Notify", "ready socket %p (%s) (input socket: %p) (fFileNum: %d)",
47  s, (s ? s->GetTitle() : "***undef***"), fInputSock, fFileNum);
48 
49  // If empty, nothing to do
50  if (!s) {
51  Warning("Notify","socket-ready list is empty!");
52  return kTRUE;
53  }
54 
55  // Handle this input
56  s->fHandler->HandleInput();
57 
58  // We are done
59  return kTRUE;
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// Get an instance of the input socket handler with 'h' as handler,
64 /// connected to socket 's'.
65 /// Create the instance, if not already existing
66 
68 {
69  if (!fgSocketHandler)
70  fgSocketHandler = new TXSocketHandler(h, s);
71  else
72  if (h && s)
73  fgSocketHandler->SetHandler(h, s);
74 
75  return fgSocketHandler;
76 }
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
static TXSocketHandler * GetSocketHandler(TFileHandler *h=0, TSocket *s=0)
Get an instance of the input socket handler with 'h' as handler, connected to socket 's'...
TH1 * h
Definition: legend2.C:5
bool Bool_t
Definition: RtypesCore.h:59
TXSocket * GetLastReady()
Return last ready socket.
Definition: TXSocket.cxx:2337
TXHandler * fHandler
Definition: TXSocket.h:95
void Info(const char *location, const char *msgfmt,...)
virtual Bool_t HandleInput(const void *in=0)
void Warning(const char *location, const char *msgfmt,...)
#define ClassImp(name)
Definition: Rtypes.h:279
void DumpReadySock()
Dump content of the ready socket list.
Definition: TXSocket.cxx:2322
static TXSocketHandler * fgSocketHandler
static TXSockPipe fgPipe
Definition: TXSocket.h:126
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
const Bool_t kTRUE
Definition: Rtypes.h:91
TXSocketHandler(TFileHandler *h, TSocket *s)