forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TXSocketHandler.cxx
75 lines (58 loc) · 2.23 KB
/
TXSocketHandler.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// @(#)root/proofx:$Id$
// Author: Gerardo Ganis 12/12/2005
/*************************************************************************
* Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
/** \class TXSocketHandler
\ingroup proofx
Input handler for XProofD sockets. These sockets cannot be directly
monitored on their descriptor, because the reading activity goes via
the internal reader thread. This class allows to handle the related issue.
*/
#include "TMonitor.h"
#include "TProof.h"
#include "TSlave.h"
#include "TXSocketHandler.h"
#include "TXHandler.h"
#include "TList.h"
ClassImp(TXSocketHandler);
// Unique instance of the socket input handler
TXSocketHandler *TXSocketHandler::fgSocketHandler = 0;
////////////////////////////////////////////////////////////////////////////////
/// Set readiness on the monitor
Bool_t TXSocketHandler::Notify()
{
if (gDebug > 2)
TXSocket::fgPipe.DumpReadySock();
// Get the socket
TXSocket *s = TXSocket::fgPipe.GetLastReady();
if (gDebug > 2)
Info("Notify", "ready socket %p (%s) (input socket: %p) (fFileNum: %d)",
s, (s ? s->GetTitle() : "***undef***"), fInputSock, fFileNum);
// If empty, nothing to do
if (!s) {
Warning("Notify","socket-ready list is empty!");
return kTRUE;
}
// Handle this input
s->fHandler->HandleInput();
// We are done
return kTRUE;
}
////////////////////////////////////////////////////////////////////////////////
/// Get an instance of the input socket handler with 'h' as handler,
/// connected to socket 's'.
/// Create the instance, if not already existing
TXSocketHandler *TXSocketHandler::GetSocketHandler(TFileHandler *h, TSocket *s)
{
if (!fgSocketHandler)
fgSocketHandler = new TXSocketHandler(h, s);
else
if (h && s)
fgSocketHandler->SetHandler(h, s);
return fgSocketHandler;
}