demux_self_piper.hpp

00001 #line 3821 "./lpsrc/flx_demux.pak"
00002 
00003 #ifndef __DEMUX_SELF_PIPER__
00004 #define __DEMUX_SELF_PIPER__
00005 
00006 #include <flx_demux_config.hpp>
00007 #include "demux_posix_demuxer.hpp"
00008 
00009 namespace flx { namespace demux {
00010 
00011 // there's no standard posix_socketio_wakeup, could be handy. could also
00012 // perhaps use it here? this is a pipe, not a socket. not sure if recv nor
00013 // send work on it, besides want to read an unlimited amount of redundant data.
00014 class DEMUX_EXTERN selfpipe_wakeup : public socket_wakeup {
00015 public:
00016   demux_callback* cb; // optional callback
00017 
00018   virtual void wakeup(posix_demuxer& demux);
00019 };
00020 
00021 class DEMUX_EXTERN auto_fd {
00022 public:
00023     int fd;
00024 
00025     auto_fd();
00026     ~auto_fd();
00027 };
00028 
00029 // make portable here? make part of the wakeup obj?
00030 class DEMUX_EXTERN pipe_pair {
00031   // self pipe trick!!! fd[0] = read end, fd[1] = write end.
00032   auto_fd         fds[2];
00033 public:
00034   pipe_pair();
00035   // void read_byte(); // done for us by wakeup obj.
00036   void write_byte();
00037   int get_read_end();
00038 };
00039 
00040 // wakes a POSIX demuxer, for when you want some kind of attention
00041 // todo: make portable
00042 class DEMUX_EXTERN self_piper {
00043     pipe_pair       pp;
00044     selfpipe_wakeup spw;
00045 public:
00046     void install(demuxer* demux, demux_callback* cb = 0);
00047     void wake();
00048 };
00049 
00050 }} // namespace demux, flx
00051 
00052 #endif

Generated on Mon Dec 11 14:48:23 2006 for Felix by  doxygen 1.5.1