|
reSIProcate/rutil
9694
|
00001 #if !defined(RESIP_FDPOLL_HXX) 00002 #define RESIP_FDPOLL_HXX 00003 00004 #include "rutil/Socket.hxx" 00005 00006 /* The Makefile system may define the following: 00007 * HAVE_EPOLL: system call epoll() is available 00008 * 00009 * An implementation based upon FdSet (and select()) is always available. 00010 * 00011 * This file and class is somewhat misnamed. It should really be 00012 * called "SocketEvent" or such. The name "FdPoll" originated 00013 * from an epoll-specific implementation. 00014 */ 00015 00016 #if defined(HAVE_EPOLL) 00017 #define RESIP_POLL_IMPL_EPOLL // Only one currently implemented 00018 #endif 00019 00020 namespace resip { 00021 00022 00023 typedef unsigned short FdPollEventMask; 00024 #define FPEM_Read 0x0001 // POLLIN 00025 #define FPEM_Write 0x0002 // POLLOUT 00026 #define FPEM_Error 0x0004 // POLLERR (select exception) 00027 #define FPEM_Edge 0x4000 // EPOLLET 00028 00029 class FdPollGrp; 00030 00037 typedef struct FdPollItemFake* FdPollItemHandle; 00038 00039 class FdPollItemIf 00040 { 00041 //friend class FdPollGrp; 00042 public: 00043 FdPollItemIf() { }; 00044 virtual ~FdPollItemIf(); 00045 00049 virtual void processPollEvent(FdPollEventMask mask) = 0; 00050 }; 00051 00052 class FdPollItemBase : public FdPollItemIf 00053 { 00054 //friend class FdPollGrp; 00055 public: 00056 FdPollItemBase(FdPollGrp *grp, Socket fd, FdPollEventMask mask); 00057 virtual ~FdPollItemBase(); 00058 00059 protected: 00060 00061 FdPollGrp* mPollGrp; 00062 Socket mPollSocket; 00063 FdPollItemHandle mPollHandle; 00064 }; 00065 00066 class FdSetIOObserver; 00067 00068 class FdPollGrp 00069 { 00070 public: 00071 FdPollGrp(); 00072 virtual ~FdPollGrp(); 00073 00075 static FdPollGrp* create(const char *implName=NULL); 00078 static const char* getImplList(); 00079 00080 virtual const char* getImplName() const = 0; 00081 00082 virtual FdPollItemHandle addPollItem(Socket sock, FdPollEventMask newMask, FdPollItemIf *item) = 0; 00083 virtual void modPollItem(FdPollItemHandle handle, FdPollEventMask newMask) = 0; 00084 virtual void delPollItem(FdPollItemHandle handle) = 0; 00085 00086 virtual void registerFdSetIOObserver(FdSetIOObserver& observer) = 0; 00087 virtual void unregisterFdSetIOObserver(FdSetIOObserver& observer) = 0; 00088 00095 virtual bool waitAndProcess(int ms=0) = 0; 00096 00100 virtual int getEPollFd() const; 00101 00102 virtual void buildFdSet(FdSet& fdSet)=0; 00103 virtual bool processFdSet(FdSet& fdset)=0; 00104 00105 protected: 00106 void processItem(FdPollItemIf *item, FdPollEventMask mask); 00107 }; 00108 00109 00110 00112 00113 } // namespace resip 00114 00115 #endif //!defined(RESIP_FDPOLL_HXX) 00116 00117 /* ==================================================================== 00118 * The Vovida Software License, Version 1.0 00119 * 00120 * Copyright (c) 2000-2005 Jacob Butcher 00121 * 00122 * Redistribution and use in source and binary forms, with or without 00123 * modification, are permitted provided that the following conditions 00124 * are met: 00125 * 00126 * 1. Redistributions of source code must retain the above copyright 00127 * notice, this list of conditions and the following disclaimer. 00128 * 00129 * 2. Redistributions in binary form must reproduce the above copyright 00130 * notice, this list of conditions and the following disclaimer in 00131 * the documentation and/or other materials provided with the 00132 * distribution. 00133 * 00134 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00135 * and "Vovida Open Communication Application Library (VOCAL)" must 00136 * not be used to endorse or promote products derived from this 00137 * software without prior written permission. For written 00138 * permission, please contact vocal@vovida.org. 00139 * 00140 * 4. Products derived from this software may not be called "VOCAL", nor 00141 * may "VOCAL" appear in their name, without prior written 00142 * permission of Vovida Networks, Inc. 00143 * 00144 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00145 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00146 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00147 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00148 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00149 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00150 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00151 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00152 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00153 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00154 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00155 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00156 * DAMAGE. 00157 * 00158 * vi: set shiftwidth=3 expandtab: 00159 */
1.7.5.1