00001 #ifndef CLASSLIB_IOSELECT_SIG_H
00002 # define CLASSLIB_IOSELECT_SIG_H
00003
00004
00005
00006 # include "IOSelectPoll.h"
00007 # if HAVE_POSIX_RT_SIGNALS && HAVE_F_SETSIG
00008 # include <sys/time.h>
00009 # include <sys/types.h>
00010 # include <unistd.h>
00011 # include <signal.h>
00012 # include <errno.h>
00013 # include <fcntl.h>
00014
00015 namespace lat {
00016
00017
00018
00019
00020
00021
00022
00048 class IOSelectSig : public IOSelectMethod
00049 {
00050 public:
00051 IOSelectSig (void);
00052 ~IOSelectSig (void);
00053
00054 virtual void setSignal (int sig);
00055
00056
00057 virtual void attach (const IOSelectRequest &req);
00058 virtual void detach (const IOSelectRequest &req);
00059 virtual void clear (void);
00060
00061
00062 virtual void setMask (IOFD fd, unsigned value);
00063 virtual void andMask (IOFD fd, unsigned value);
00064 virtual void orMask (IOFD fd, unsigned value);
00065
00066
00067 virtual bool wait (long msecs);
00068 virtual IOFD next (IOSelectEvent &event, IOSelectCB &cb);
00069
00070 private:
00071 static const int UNUSED = -2;
00072 static const int UNLINKED = -1;
00073
00074 void addReady (IOFD fd);
00075 void delReady (IOFD fd);
00076 void updateReady (IOFD fd);
00077
00079 struct item {
00085 IOFD m_next;
00086
00092 IOFD m_prev;
00093
00095 unsigned m_mask;
00096
00098 unsigned m_ready;
00099
00101 size_t m_index;
00102 };
00103
00104 IOSelectPoll *m_fallback;
00105 int m_signal;
00106 sigset_t m_sigset;
00107 IOFD m_readylist;
00108 size_t m_nready;
00109 size_t m_nfds;
00110 std::vector<item> m_fds;
00111 };
00112
00113
00114
00115
00116 }
00117 # endif // HAVE_POSIX_RT_SIGNALS && HAVE_F_SETSIG
00118 #endif // CLASSLIB_IOSELECT_SIG_H