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

poller.h

00001 /************************************************************************
00002  *
00003  * $Id: poller.h,v 1.13 2002/03/19 00:36:11 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_H
00028 #define POLLER_H
00029 
00030 #include "poller_util.h"
00031 
00033 namespace fpoller {
00034   extern const short WRITE; 
00035   extern const short READ;
00036 
00040   template<typename Delegate> 
00041     class basic_poller {
00042     private:
00043       Delegate delegate_;
00044     public:
00046       basic_poller():delegate_(){}
00048       void add(int fd,short interest, callback * cb){ delegate_.add(fd,interest,cb); }
00050       void remove(int fd,short interest){ delegate_.remove(fd,interest); }
00052       void remove(int fd){ remove(fd,WRITE); remove(fd,READ); }
00055       int poll(int timeout){return delegate_.poll(timeout);}
00056     };
00057 }
00058 
00059 #include "poller_generic.h"
00060 namespace fpoller { 
00062   typedef basic_poller<poller_generic> traditional_poller;
00063 }
00064 
00065 #ifdef POLLER_DEVPOLL
00066 #include "poller_devpoll.h"
00067 namespace fpoller { 
00068   typedef basic_poller<poller_devpoll> fast_poller;
00069   typedef fast_poller poller;
00070 }
00071 #endif
00072 
00073 #ifdef POLLER_KQUEUE
00074 #include "poller_kqueue.h"
00075 namespace fpoller { 
00076   typedef basic_poller<poller_kqueue> fast_poller;
00077   typedef fast_poller poller;
00078 }
00079 #endif
00080 
00081 #ifndef POLLER_KQUEUE
00082 #ifndef POLLER_DEVPOLL
00083 namespace fpoller{ 
00088   typedef traditional_poller poller;
00089 }
00090 #endif
00091 #endif
00092 
00093 #endif //POLLER_H
00094 
00095 
00096 
00097 
00098 
00099 

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