faio_posixio.hpp

00001 #line 4 "./lpsrc/flx_posixio.ipk"
00002 #ifndef __FLX_FAIO_POSIXIO_H__
00003 #define __FLX_FAIO_POSIXIO_H__
00004 #include <flx_faio_config.hpp>
00005 
00006 #include "faio_asyncio.hpp"
00007 
00008 // we don't need to piggyback much data at all. for now just the demuxer,
00009 // so that we can be woken up, and the buffer info (this replaces the
00010 // felix "socket" thread type, which was ugly.
00011 
00012 #include "demux_posix_demuxer.hpp"
00013 
00014 // a new sort of demuxer/event source: file io completions
00015 // haven't given up on using the socket style demuxers yet.
00016 #include "demux_pfileio.hpp"
00017 
00018 #include "demux_timer_queue.hpp"
00019 
00020 namespace flx { namespace faio {
00021 
00022 class FAIO_EXTERN socketio_wakeup : public demux::socket_wakeup {
00023 public:
00024   demux::sel_param   pb;     // in: what you want, out: what you get
00025   int       sio_flags;  // either one of PDEMUX_{READ|WRITE}A
00026   struct socketio_request *request;
00027 
00028   virtual void wakeup(demux::posix_demuxer& demux);
00029 };
00030 
00031 // this can handle most unix style io, that is, read & write on sockets,
00032 // files & pipes. NICE. the fact that the socket is now in here may mean
00033 // I can get rid of the epoll hack
00034 // Not sure if this can be used for file fds.
00035 class FAIO_EXTERN socketio_request : public flx_driver_request_base {
00036 public:
00037     socketio_wakeup sv;
00038     demux::posix_demuxer *pd;
00039     socketio_request() {}       // Lord Felix demands it. Like STL.
00040     socketio_request(socketio_request const&);
00041     void operator = (socketio_request const&);
00042 
00043     socketio_request(demux::posix_demuxer *pd_a, int s, char* buf, long len, bool r);
00044     bool start_async_op_impl();
00045 };
00046 
00047 // client open
00048 class FAIO_EXTERN connect_request
00049   : public flx_driver_request_base, public demux::connect_control_block {
00050 public:
00051   demux::posix_demuxer *pd;
00052   connect_request() {}      // flx linkage
00053 
00054   connect_request(demux::posix_demuxer *pd_a,const char* addr, int port);
00055   bool start_async_op_impl();
00056   virtual void wakeup(demux::posix_demuxer&);
00057 };
00058 
00059 // server open
00060 class FAIO_EXTERN accept_request
00061   : public flx_driver_request_base, public demux::accept_control_block {
00062 public:
00063   // we sometimes know that there'll be several connections to accept.
00064   // this'll need a different wakeup - and a different interface between
00065   // event source & wakeups
00066 
00067   demux::posix_demuxer *pd;
00068   accept_request() {} // flx linkage
00069 
00070   // eeh, give that a better name
00071   accept_request(demux::posix_demuxer *pd_a, int listener) : pd(pd_a) { s = listener; }
00072 
00073   // from flx_driver_request_base
00074   bool start_async_op_impl();
00075 
00076   // from accept_control_block
00077   virtual void wakeup(demux::posix_demuxer& demux);
00078 };
00079 
00080 
00081 // separate pthread file io
00082 // hum. multiple inheritance
00083 class FAIO_EXTERN flxfileio_request
00084     : public flx_driver_request_base, public demux::fileio_request
00085 {
00086     pthread::worker_fifo       *aio_worker;
00087 public:
00088     flxfileio_request();           // flx linkage
00089     ~flxfileio_request();          // flx linkage
00090 
00091     flxfileio_request(
00092       pthread::worker_fifo *a,
00093       int f, char* buf, long len, long off, bool rd
00094      )
00095         : fileio_request(f, buf, len, off, rd), aio_worker(a)
00096      {
00097        //fprintf(stderr, "flxfilio_request ctor\n");
00098      }
00099 
00100     // from driver request
00101     bool start_async_op_impl();
00102     void finished(); // fileio_request
00103 };
00104 
00105 }}
00106 #endif
00107 

Generated on Thu May 29 14:36:12 2008 for Felix by  doxygen 1.5.5