00001 #ifndef _UNEVT_UnixEventPoll_H_ // -*-c++-*-
00002
00003 #ifdef __GNUG__
00004 # pragma interface
00005 #endif
00006
00007
00008
00009
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
00029
00030
00031
00032
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
00043 UnixEventPoll(Dispatcher *dispatcher);
00044
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
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 }
00092 }
00093
00094 #endif