Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages   Examples  

poller_devpoll.h

00001 /************************************************************************
00002  *
00003  * $Id: poller_devpoll.h,v 1.11 2001/08/19 00:31:53 crooney Exp $
00004  *
00005  ***********************************************************************/
00006 
00007 /**************************************************************************
00008 Copyright 2001, Christopher Rooney crooney@crooney.com
00009 
00010 This file is part of fpoller.
00011 
00012 fpoller is free software; you can redistribute it and/or modify
00013 it under the terms of the GNU General Public License as published by
00014 the Free Software Foundation; either version 2 of the License, or
00015 (at your option) any later version.
00016 
00017 fpoller is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 GNU General Public License for more details.
00021 
00022 You should have received a copy of the GNU General Public License
00023 along with fpoller; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 
00027 #ifndef POLLER_DEVPOLL_H
00028 #define POLLER_DEVPOLL_H
00029 
00030 #include <unistd.h>
00031 #include <poll.h>
00032 #include <hash_map>
00033 #include <sys/devpoll.h>
00034 
00035 #include "poller_util.h"
00036 
00037 namespace fpoller {
00044   class poller_devpoll {
00045   private:
00046     vector<struct pollfd> pollfds_, changefds_;
00047     typedef std::hash_map<int, callback_wrapper> fd_map;
00048     struct fd_maps {
00049       fd_map reader,writer;
00050       inline fd_map &get_map(short interest){return (interest & WRITE) ? writer : reader;}
00051     };
00052     fd_maps fd_maps_;
00053     //int num_changed_;
00054     int devpoll_fd_;
00055     dvpoll dvpoll_;
00056   public:
00058     poller_devpoll();
00060     ~poller_devpoll();
00061     void add(int fd, short events, callback *cb);
00062     void remove(int fd,short interest);
00063     int poll(int timeout);
00064   };
00065 }//namespace
00066 
00067 #endif

Generated at Wed Oct 16 16:02:39 2002 for fpoller by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001