demux_select_demuxer.hpp

00001 #line 3 "./lpsrc/flx_select_demux.ipk"
00002 #ifndef __FLX_DEMUX_SELECT_DEMUXER_H__
00003 #define __FLX_DEMUX_SELECT_DEMUXER_H__
00004 
00005 #include "demux_posix_demuxer.hpp"
00006 #include <sys/types.h>    // for sys/select.h on osx
00007 #include <sys/select.h>   // for fd_set
00008 #include <sys/time.h>     // GUSI WTF?
00009 #include <unistd.h>       // for bsd
00010 
00011 // Unlike the other demuxers, this one is NOT thread safe, so wait and
00012 // add socket wakeup must only be called from the same thread.
00013 // if you're looking for the thread safe version, try ts_select_demuxer
00014 
00015 namespace flx { namespace demux {
00016 
00017 class DEMUX_EXTERN select_demuxer : public posix_demuxer {
00018   void  remove_fd(int s);
00019 
00020   // thanks Beej!
00021   fd_set      master_read_set;    // fd watched for reading
00022   fd_set      master_write_set;   // for writing
00023   fd_set      master_except_set;    // for exceptions
00024 
00025   // read sveglias - note we only have one set, so currently this demuxer
00026   // cannot have separate wakeups for the same file descriptor. this
00027   // fits in fine with the "undefined" nature of doing that.
00028   socket_wakeup*  svs[FD_SETSIZE];    // read sveglias
00029   //socket_wakeup*  write_svs[FD_SETSIZE];  // write wakeups
00030 
00031   int       fdmax;          // high watermark for select
00032 
00033 protected:
00034   virtual void  get_evts(bool poll);
00035 
00036 public:
00037   // get_evts broken into pieces for thread safe implementations
00038   void copy_sets(fd_set& rset, fd_set& wset, fd_set& exset);
00039   // returns true if process_sets should be called.
00040   bool select(fd_set& rset, fd_set& wset, fd_set& exset, bool poll);
00041   // these could be consts
00042   void process_sets(fd_set& rset, fd_set& wset, fd_set& exset);
00043 
00044   select_demuxer();
00045 
00046   virtual int   add_socket_wakeup(socket_wakeup* sv, int flags);
00047 };
00048 }} // namespace demux, flx
00049 #endif
00050 

Generated on Thu May 29 14:05:03 2008 for Felix by  doxygen 1.5.5