Logo ROOT   6.18/05
Reference Guide
TMonitor.h
Go to the documentation of this file.
1// @(#)root/net:$Id$
2// Author: Fons Rademakers 09/01/97
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, 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#ifndef ROOT_TMonitor
13#define ROOT_TMonitor
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TMonitor //
19// //
20// This class monitors activity on a number of network sockets. //
21// The actual monitoring is done by TSystem::DispatchOneEvent(). //
22// Typical usage: create a TMonitor object. Register a number of //
23// TSocket objects and call TMonitor::Select(). Select() returns the //
24// socket object which has data waiting. TSocket objects can be added, //
25// removed, (temporary) enabled or disabled. //
26// //
27//////////////////////////////////////////////////////////////////////////
28
29#include "TObject.h"
30#include "TQObject.h"
31
32class TList;
33class TSocket;
34
35
36class TMonitor : public TObject, public TQObject {
37
38friend class TSocketHandler;
39friend class TTimeOutTimer;
40friend class TXSlave;
41friend class TXSocket;
42
43private:
44 TList *fActive; //list of sockets to monitor
45 TList *fDeActive; //list of (temporary) disabled sockets
46 TSocket *fReady; //socket which is ready to be read or written
47 Bool_t fMainLoop; //true if monitoring sockets within the main event loop
48 Bool_t fInterrupt; //flags an interrupt to Select
49
50 void SetReady(TSocket *sock);
51 void *GetSender() { return this; } // used to get gTQSender
52
53public:
54 enum EInterest { kRead = 1, kWrite = 2 };
55
56 TMonitor(Bool_t mainloop = kTRUE);
57 TMonitor(const TMonitor &m);
58 virtual ~TMonitor();
59
60 virtual void Add(TSocket *sock, Int_t interest = kRead);
61 virtual void SetInterest(TSocket *sock, Int_t interest = kRead);
62 virtual void Remove(TSocket *sock);
63 virtual void RemoveAll();
64
65 virtual void Activate(TSocket *sock);
66 virtual void ActivateAll();
67 virtual void DeActivate(TSocket *sock);
68 virtual void DeActivateAll();
69 virtual void Ready(TSocket *sock); // *SIGNAL*
70
73
74 TSocket *Select();
75 TSocket *Select(Long_t timeout);
76 Int_t Select(TList *rdready, TList *wrready, Long_t timeout);
77
78 Int_t GetActive(Long_t timeout = -1) const;
79 Int_t GetDeActive() const;
80 TList *GetListOfActives() const;
82
83 Bool_t IsActive(TSocket *s) const;
84
85 ClassDef(TMonitor,0) //Monitor activity on a set of TSocket objects
86};
87
88#endif
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
A doubly linked list.
Definition: TList.h:44
Bool_t fInterrupt
Definition: TMonitor.h:48
friend class TTimeOutTimer
Definition: TMonitor.h:39
virtual void Ready(TSocket *sock)
Emit signal when some socket is ready.
Definition: TMonitor.cxx:530
void SetReady(TSocket *sock)
Called by TSocketHandler::Notify() to signal which socket is ready to be read or written.
Definition: TMonitor.cxx:423
virtual void SetInterest(TSocket *sock, Int_t interest=kRead)
Set interest mask for socket sock to interest.
Definition: TMonitor.cxx:180
TList * fDeActive
Definition: TMonitor.h:45
virtual void RemoveAll()
Remove all sockets from the monitor.
Definition: TMonitor.cxx:241
virtual void ActivateAll()
Activate all de-activated sockets.
Definition: TMonitor.cxx:268
@ kWrite
Definition: TMonitor.h:54
@ kRead
Definition: TMonitor.h:54
TSocket * Select()
Return pointer to socket for which an event is waiting.
Definition: TMonitor.cxx:322
friend class TSocketHandler
Definition: TMonitor.h:38
virtual void Activate(TSocket *sock)
Activate a de-activated socket.
Definition: TMonitor.cxx:250
virtual void Add(TSocket *sock, Int_t interest=kRead)
Add socket to the monitor's active list.
Definition: TMonitor.cxx:168
void ResetInterrupt()
Definition: TMonitor.h:72
Int_t GetActive(Long_t timeout=-1) const
Return number of sockets in the active list.
Definition: TMonitor.cxx:438
TMonitor(Bool_t mainloop=kTRUE)
Create a monitor object.
Definition: TMonitor.cxx:109
TList * fActive
Definition: TMonitor.h:44
virtual ~TMonitor()
Cleanup the monitor object. Does not delete sockets being monitored.
Definition: TMonitor.cxx:153
virtual void DeActivateAll()
De-activate all activated sockets.
Definition: TMonitor.cxx:302
TSocket * fReady
Definition: TMonitor.h:46
virtual void DeActivate(TSocket *sock)
De-activate a socket.
Definition: TMonitor.cxx:284
TList * GetListOfActives() const
Returns a list with all active sockets.
Definition: TMonitor.cxx:498
void * GetSender()
Definition: TMonitor.h:51
TList * GetListOfDeActives() const
Returns a list with all de-active sockets.
Definition: TMonitor.cxx:515
virtual void Remove(TSocket *sock)
Remove a socket from the monitor.
Definition: TMonitor.cxx:214
Bool_t fMainLoop
Definition: TMonitor.h:47
Bool_t IsActive(TSocket *s) const
Check if socket 's' is in the active list.
Definition: TMonitor.cxx:482
Int_t GetDeActive() const
Return number of sockets in the de-active list.
Definition: TMonitor.cxx:473
void Interrupt()
Definition: TMonitor.h:71
Mother of all ROOT objects.
Definition: TObject.h:37
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition: TQObject.h:48
This is the version of TSlave for workers servers based on XProofD.
Definition: TXSlave.h:32
High level handler of connections to XProofD.
Definition: TXSocket.h:59
static constexpr double s
auto * m
Definition: textangle.C:8