reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
FdPoll.hxx
Go to the documentation of this file.
1#if !defined(RESIP_FDPOLL_HXX)
2#define RESIP_FDPOLL_HXX
3
4#include "rutil/Socket.hxx"
5
6/* The Makefile system may define the following:
7 * HAVE_EPOLL: system call epoll() is available
8 * HAVE_POLL: system call poll() is available (Windows uses WSAPoll())
9 *
10 * An implementation based upon FdSet (and select()) is always available.
11 *
12 * This file and class is somewhat misnamed. It should really be
13 * called "SocketEvent" or such. The name "FdPoll" originated
14 * from an epoll-specific implementation.
15 */
16
17#if defined(HAVE_EPOLL)
18#define RESIP_POLL_IMPL_EPOLL
19#endif
20
21#if defined(HAVE_POLL) || (_WIN32_WINNT >= 0x0600)
22#define RESIP_POLL_IMPL_POLL
23#endif
24
25namespace resip {
26
27
28typedef unsigned short FdPollEventMask;
29#define FPEM_Read 0x0001 // POLLIN
30#define FPEM_Write 0x0002 // POLLOUT
31#define FPEM_Error 0x0004 // POLLERR (select exception)
32#define FPEM_Edge 0x4000 // EPOLLET
33
34class FdPollGrp;
35
43
45{
46 //friend class FdPollGrp;
47 public:
49 virtual ~FdPollItemIf();
50
54 virtual void processPollEvent(FdPollEventMask mask) = 0;
55};
56
58{
59 //friend class FdPollGrp;
60 public:
62 virtual ~FdPollItemBase();
63
64 protected:
65
69};
70
72{
73 public:
74 FdPollGrp();
75 virtual ~FdPollGrp();
76
77 typedef enum {FdSetImpl = 0, PollImpl, EPollImpl } ImplType;
78
80 static FdPollGrp* create(const char *implName=NULL);
83 static const char* getImplList();
84
85 virtual const char* getImplName() const = 0;
86 virtual ImplType getImplType() const = 0;
87
89 virtual void modPollItem(FdPollItemHandle handle, FdPollEventMask newMask) = 0;
90 virtual void delPollItem(FdPollItemHandle handle) = 0;
91
98 virtual bool waitAndProcess(int ms=0) = 0;
99
103 virtual int getEPollFd() const;
104
105 // Legacy API's (deprecated) - use waitAndProcess instead
106 virtual void buildFdSet(FdSet& fdSet)=0;
107 virtual bool processFdSet(FdSet& fdset)=0;
108
109 protected:
110 void processItem(FdPollItemIf *item, FdPollEventMask mask);
111};
112
113
114
116
117} // namespace resip
118
119#endif
120
121/* ====================================================================
122 * The Vovida Software License, Version 1.0
123 *
124 * Copyright (c) 2000-2005 Jacob Butcher
125 *
126 * Redistribution and use in source and binary forms, with or without
127 * modification, are permitted provided that the following conditions
128 * are met:
129 *
130 * 1. Redistributions of source code must retain the above copyright
131 * notice, this list of conditions and the following disclaimer.
132 *
133 * 2. Redistributions in binary form must reproduce the above copyright
134 * notice, this list of conditions and the following disclaimer in
135 * the documentation and/or other materials provided with the
136 * distribution.
137 *
138 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
139 * and "Vovida Open Communication Application Library (VOCAL)" must
140 * not be used to endorse or promote products derived from this
141 * software without prior written permission. For written
142 * permission, please contact vocal@vovida.org.
143 *
144 * 4. Products derived from this software may not be called "VOCAL", nor
145 * may "VOCAL" appear in their name, without prior written
146 * permission of Vovida Networks, Inc.
147 *
148 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
149 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
150 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
151 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
152 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
153 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
154 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
155 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
156 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
157 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
158 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
159 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
160 * DAMAGE.
161 *
162 * vi: set shiftwidth=3 expandtab:
163 */
Handles cross-platform sockets compatibility.
void processItem(FdPollItemIf *item, FdPollEventMask mask)
Definition FdPoll.cxx:69
static const char * getImplList()
Return candidate impl names with vertical bar (|) between them Intended for help messages.
Definition FdPoll.cxx:997
static FdPollGrp * create(const char *implName=NULL)
factory
Definition FdPoll.cxx:972
virtual FdPollItemHandle addPollItem(Socket sock, FdPollEventMask newMask, FdPollItemIf *item)=0
virtual ImplType getImplType() const =0
virtual ~FdPollGrp()
Definition FdPoll.cxx:64
virtual int getEPollFd() const
get the epoll-fd (epoll_create()) This is fd (type int), not Socket.
Definition FdPoll.cxx:89
virtual void buildFdSet(FdSet &fdSet)=0
virtual bool processFdSet(FdSet &fdset)=0
virtual void delPollItem(FdPollItemHandle handle)=0
virtual void modPollItem(FdPollItemHandle handle, FdPollEventMask newMask)=0
virtual bool waitAndProcess(int ms=0)=0
Wait at most {ms} milliseconds.
virtual const char * getImplName() const =0
FdPollGrp * mPollGrp
Definition FdPoll.hxx:66
FdPollItemHandle mPollHandle
Definition FdPoll.hxx:68
virtual ~FdPollItemBase()
Definition FdPoll.cxx:39
virtual void processPollEvent(FdPollEventMask mask)=0
Called by PollGrp when activity is possible.
virtual ~FdPollItemIf()
Definition FdPoll.cxx:26
Object-oriented wrapper for your platform's file-descriptor set.
Definition Socket.hxx:162
dcm! – add UnusedChecking(_enum) below;
unsigned short FdPollEventMask
Definition FdPoll.hxx:28
int Socket
Definition Socket.hxx:94
struct FdPollItemFake * FdPollItemHandle
This is opaque type used to identify a particular Item.
Definition FdPoll.hxx:42
void list()
Definition userAdmin.cxx:66