Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TMonitor.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/net:$Id$
0002 // Author: Fons Rademakers   09/01/97
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TMonitor
0013 #define ROOT_TMonitor
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TMonitor                                                             //
0019 //                                                                      //
0020 // This class monitors activity on a number of network sockets.         //
0021 // The actual monitoring is done by TSystem::DispatchOneEvent().        //
0022 // Typical usage: create a TMonitor object. Register a number of        //
0023 // TSocket objects and call TMonitor::Select(). Select() returns the    //
0024 // socket object which has data waiting. TSocket objects can be added,  //
0025 // removed, (temporary) enabled or disabled.                            //
0026 //                                                                      //
0027 //////////////////////////////////////////////////////////////////////////
0028 
0029 #include "TObject.h"
0030 #include "TQObject.h"
0031 
0032 class TList;
0033 class TSocket;
0034 
0035 
0036 class TMonitor : public TObject, public TQObject {
0037 
0038 friend class TSocketHandler;
0039 friend class TTimeOutTimer;
0040 friend class TXSlave;
0041 friend class TXSocket;
0042 
0043 private:
0044    TList    *fActive;     //list of sockets to monitor
0045    TList    *fDeActive;   //list of (temporary) disabled sockets
0046    TSocket  *fReady;      //socket which is ready to be read or written
0047    Bool_t    fMainLoop;   //true if monitoring sockets within the main event loop
0048    Bool_t    fInterrupt;  //flags an interrupt to Select
0049 
0050    void  SetReady(TSocket *sock);
0051    void *GetSender() override { return this; }  // used to get gTQSender
0052 
0053 public:
0054    enum EInterest { kRead = 1, kWrite = 2 };
0055 
0056    TMonitor(Bool_t mainloop = kTRUE);
0057    TMonitor(const TMonitor &m);
0058    virtual ~TMonitor();
0059 
0060    virtual void Add(TSocket *sock, Int_t interest = kRead);
0061    virtual void SetInterest(TSocket *sock, Int_t interest = kRead);
0062    virtual void Remove(TSocket *sock);
0063    virtual void RemoveAll();
0064 
0065    virtual void Activate(TSocket *sock);
0066    virtual void ActivateAll();
0067    virtual void DeActivate(TSocket *sock);
0068    virtual void DeActivateAll();
0069    virtual void Ready(TSocket *sock); // *SIGNAL*
0070 
0071    void     Interrupt() { fInterrupt = kTRUE; }
0072    void     ResetInterrupt() { fInterrupt = kFALSE; }
0073 
0074    TSocket *Select();
0075    TSocket *Select(Long_t timeout);
0076    Int_t    Select(TList *rdready, TList *wrready, Long_t timeout);
0077 
0078    Int_t  GetActive(Long_t timeout = -1) const;
0079    Int_t  GetDeActive() const;
0080    TList *GetListOfActives() const;
0081    TList *GetListOfDeActives() const;
0082 
0083    Bool_t IsActive(TSocket *s) const;
0084 
0085    ClassDefOverride(TMonitor,0)  //Monitor activity on a set of TSocket objects
0086 };
0087 
0088 #endif