Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

UnixEventPoll.h

00001 #ifndef _UNEVT_UnixEventPoll_H_  // -*-c++-*-
00002 
00003 #ifdef __GNUG__
00004 #  pragma interface
00005 #endif
00006 
00007 /* $Header: /home/hopper/src/cvs/C++/UniEvent/UniEvent/UnixEventPoll.h,v 1.10 2002/08/29 00:58:05 hopper Exp $ */
00008 
00009 // For a log, see ../ChangeLog
00010 
00011 #ifndef _UNEVT_UnixEventRegistry_H_
00012 #  include <UniEvent/UnixEventRegistry.h>
00013 #endif
00014 #ifndef _UNEVT_Timer_H_
00015 #  include <UniEvent/Timer.h>
00016 #endif
00017 #ifndef _UNEVT_TimerEventTracker_H_
00018 #  include <UniEvent/TimerEventTracker.h>
00019 #endif
00020 
00021 #include <LCore/Debugable.h>
00022 
00023 #define _UNEVT_UnixEventPoll_H_
00024 
00025 namespace strmod {
00026 namespace unievent {
00027 
00028 /** \class UnixEventPoll UnixEventPoll.h UniEvent/UnixEventPoll.h
00029  * \brief Manages events associated with various file descriptors and/or
00030  * signals.
00031  * This is an implementation of UnixEventRegistry that uses the
00032  * poll(2) system call to find out about events.
00033  */
00034 class UnixEventPoll : virtual public UnixEventRegistry,
00035                       virtual public lcore::Debugable,
00036                       virtual public Timer,
00037                       private TimerEventTracker
00038 {
00039  public:
00040    static const UNEVT_ClassIdent identifier;
00041 
00042    //! Construct to use \c dispatcher to post events to. 
00043    UnixEventPoll(Dispatcher *dispatcher);
00044    //! Currently doesn't clean signal handlers.
00045    virtual ~UnixEventPoll();
00046 
00047    virtual int AreYouA(const lcore::ClassIdent &cid) const {
00048       return((identifier == cid) || Timer::AreYouA(cid)
00049              || Debugable::AreYouA(cid));
00050    }
00051 
00052    virtual bool invariant() const;
00053    virtual void printState(::std::ostream &os) const;
00054 
00055    virtual void registerFDCond(int fd,
00056                                const FDCondSet &condbits,
00057                                const EventPtr &ev);
00058 
00059    virtual void freeFD(int fd);
00060 
00061    virtual void onSignal(int signo, const EventPtr &e);
00062 
00063    virtual void clearSignal(int signo, const EventPtr &e);
00064 
00065    virtual void clearSignal(int signo);
00066 
00067    using TimerEventTracker::postAt;
00068    using TimerEventTracker::postIn;
00069 
00070    //! Uses the POSIX gettimeofday call.
00071    virtual absolute_t currentTime() const;
00072 
00073    virtual void doPoll(bool wait = false);
00074 
00075  protected:
00076    virtual const lcore::ClassIdent *i_GetIdent() const  { return &identifier; }
00077 
00078  private:
00079    struct Imp;
00080 
00081    Imp &impl_;
00082    Dispatcher * const dispatcher_;
00083 
00084    static void signalHandler(int signo);
00085    void handleSignal(int signo);
00086    void unHandleSignal(int signo);
00087    void sigOccurred(int signo);
00088    bool postSigEvents();
00089 };
00090 
00091 } // namespace unievent
00092 } // namespace strmod
00093 
00094 #endif

Generated on Wed Jan 29 00:32:45 2003 for libNet by doxygen1.3-rc1