reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Poll.hxx
Go to the documentation of this file.
1
#if !defined(RESIP_POLL_HXX)
2
#define RESIP_POLL_HXX
3
4
#include <memory>
5
#include <vector>
6
7
namespace
resip
{
8
10
11
class
PollImpl;
12
25
class
Poll
{
26
27
public
:
28
29
class
FDEntry
{
30
31
friend
class
Poll
;
32
33
public
:
34
35
typedef
unsigned
short
StateBitMask
;
// FDStateBitMask | ResipStateBitMask.
36
enum
FDStateBitMaskEnum
{
37
fdsbmReadable
= 0x0001,
// (POLLIN)
38
fdsbmWritable
= 0x0004,
// (POLLOUT)
39
fdsbmError
= 0x0008,
// (POLLERR)
40
fdsbmAll
=
Poll::FDEntry::fdsbmReadable
|
41
Poll::FDEntry::fdsbmWritable
|
42
Poll::FDEntry::fdsbmError
43
};
44
typedef
StateBitMask
FDStateBitMask
;
45
enum
ResipStateBitMaskEnum
{
46
rsbmIsTransport
= 0x0040,
47
rsbmIsWritePending
= 0x0080
48
};
49
typedef
StateBitMask
ResipStateBitMask
;
50
51
private
:
52
53
static
54
int
55
compare(
const
Poll::FDEntry
*
leftFDEntry
,
56
const
Poll::FDEntry
*
rightFDEntry
);
57
58
// Fields:
59
Poll
* _poll;
60
int
/*FD*/
_fd;
61
Poll::FDEntry::StateBitMask
_stateBitMask;
62
unsigned
short
_index;
// Within "_poll->_fdEntryVector".
63
64
public
:
65
66
//constructor
67
FDEntry
(
Poll
* poll,
68
bool
isTransport
,
69
int
/*FD*/
fd);
70
71
//destructor
72
virtual
~FDEntry
();
73
74
inline
75
int
//FD
76
getFD
()
const
77
{
78
return
_fd;
79
}
80
81
inline
82
Poll::FDEntry::StateBitMask
83
getStateBitMask
()
const
84
{
85
return
_stateBitMask;
86
}
87
88
void
89
clearFDState
();
90
91
protected
:
92
93
void
94
setIsWritePending
(
bool
isWritePending
);
95
96
virtual
void
doRead
() {};
97
virtual
void
doWrite
() {};
98
virtual
void
doError
() {};
99
100
private
:
101
102
// Copy constructor: declared but not defined
103
FDEntry
(
const
Poll::FDEntry
& from);
104
105
// Assignment: declared but not defined
106
Poll::FDEntry
&
107
operator=(
const
Poll::FDEntry
& from);
108
109
};
110
friend
class
Poll::FDEntry
;
111
112
private
:
113
std::unique_ptr<PollImpl> mImpl;
114
public
:
115
116
/*
117
"waitResult" is the result of method "wait" or "afterExternWait".
118
Returns the index of the entry with the smallest file descriptor >= "fd" in
119
"waitResult", or "waitResult.size()" if none exists.
120
*/
121
static
122
int
123
findFDInWaitResult
(
int
/*FD*/
fd,
124
const
std::vector<Poll::FDEntry *> &
waitResult
);
125
126
//constructor
127
Poll
();
128
129
//destructor
130
~Poll
();
131
132
#ifdef RESIP_POLL_EXTERN
// {
133
134
// The result is the set of entries in this poll object.
135
const
std::vector<Poll::FDEntry *> &
136
beforeExternWait
();
137
138
/*
139
If "fd" has no entry in this poll object, ignore it and return false.
140
Otherwise, set the entry's FD state from "fdStateBitMask" and return true.
141
If the same "fd" is passed in multiple times, the "fdStateBitMask" are
142
or-ed together.
143
*/
144
bool
145
setEntryFDStateForExternWait
(
int
/*FD*/
fd,
146
Poll::FDEntry::StateBitMask
fdStateBitMask
);
147
148
// The result is identical to that of method "wait".
149
const
std::vector<Poll::FDEntry *> &
150
afterExternWait
();
151
152
#else
153
154
/*
155
Wait for I/O on any of this poll object's entry's file descriptors.
156
More precisely, wait for the file descriptor of any entry with a pending
157
write to be writable or for any entry's file descriptor to have readable
158
input or an error.
159
If "timeoutMilliSeconds" is negative, it means wait indefinitely, otherwise
160
it indicates the maximum period to wait.
161
The result is an array of the entries for the file descriptors that are
162
readable, writable, or error, as specified by each entry's FD state.
163
The result contains no duplicates and is sorted by file descriptor.
164
(To service file descriptors with round-robin prioritization, remember the
165
last file descriptor serviced and use method "Poll::findFDInWaitResult" to
166
find the index in the result array of the highest priority entry.)
167
The result is valid until the next call to this method, method
168
"beforeExternWait", or the destructor.
169
At some point before then, for each entry in the result, method
170
"Poll::FDEntry::clearFDState" must be called.
171
*/
172
const
std::vector<Poll::FDEntry *> &
173
wait
(
int
timeoutMilliSeconds
);
174
175
#endif
176
177
private
:
178
179
// Copy constructor: declared but not defined
180
Poll
(
const
Poll
& from);
181
182
// Assignment: declared but not defined
183
Poll
&
184
operator=(
const
Poll
& from);
185
186
};
187
189
190
}
// namespace resip
191
192
#endif
193
194
/* ====================================================================
195
* The Vovida Software License, Version 1.0
196
*
197
* Copyright (c) 2000-2005 Jacob Butcher
198
*
199
* Redistribution and use in source and binary forms, with or without
200
* modification, are permitted provided that the following conditions
201
* are met:
202
*
203
* 1. Redistributions of source code must retain the above copyright
204
* notice, this list of conditions and the following disclaimer.
205
*
206
* 2. Redistributions in binary form must reproduce the above copyright
207
* notice, this list of conditions and the following disclaimer in
208
* the documentation and/or other materials provided with the
209
* distribution.
210
*
211
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
212
* and "Vovida Open Communication Application Library (VOCAL)" must
213
* not be used to endorse or promote products derived from this
214
* software without prior written permission. For written
215
* permission, please contact vocal@vovida.org.
216
*
217
* 4. Products derived from this software may not be called "VOCAL", nor
218
* may "VOCAL" appear in their name, without prior written
219
* permission of Vovida Networks, Inc.
220
*
221
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
222
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
223
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
224
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
225
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
226
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
227
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
228
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
229
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
230
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
232
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
233
* DAMAGE.
234
*
235
*/
resip::Poll::FDEntry
Definition
Poll.hxx:29
resip::Poll::FDEntry::ResipStateBitMask
StateBitMask ResipStateBitMask
Definition
Poll.hxx:49
resip::Poll::FDEntry::FDStateBitMaskEnum
FDStateBitMaskEnum
Definition
Poll.hxx:36
resip::Poll::FDEntry::fdsbmError
@ fdsbmError
Definition
Poll.hxx:39
resip::Poll::FDEntry::fdsbmAll
@ fdsbmAll
Definition
Poll.hxx:40
resip::Poll::FDEntry::fdsbmReadable
@ fdsbmReadable
Definition
Poll.hxx:37
resip::Poll::FDEntry::fdsbmWritable
@ fdsbmWritable
Definition
Poll.hxx:38
resip::Poll::FDEntry::getStateBitMask
Poll::FDEntry::StateBitMask getStateBitMask() const
Definition
Poll.hxx:83
resip::Poll::FDEntry::getFD
int getFD() const
Definition
Poll.hxx:76
resip::Poll::FDEntry::ResipStateBitMaskEnum
ResipStateBitMaskEnum
Definition
Poll.hxx:45
resip::Poll::FDEntry::rsbmIsTransport
@ rsbmIsTransport
Definition
Poll.hxx:46
resip::Poll::FDEntry::rsbmIsWritePending
@ rsbmIsWritePending
Definition
Poll.hxx:47
resip::Poll::FDEntry::StateBitMask
unsigned short StateBitMask
Definition
Poll.hxx:35
resip::Poll::FDEntry::~FDEntry
virtual ~FDEntry()
Definition
Poll.cxx:116
resip::Poll::FDEntry::doRead
virtual void doRead()
Definition
Poll.hxx:96
resip::Poll::FDEntry::clearFDState
void clearFDState()
Definition
Poll.cxx:138
resip::Poll::FDEntry::doError
virtual void doError()
Definition
Poll.hxx:98
resip::Poll::FDEntry::setIsWritePending
void setIsWritePending(bool isWritePending)
Definition
Poll.cxx:144
resip::Poll::FDEntry::FDStateBitMask
StateBitMask FDStateBitMask
Definition
Poll.hxx:44
resip::Poll::FDEntry::doWrite
virtual void doWrite()
Definition
Poll.hxx:97
resip::Poll
This class abstracts the Unix system call "poll".
Definition
Poll.hxx:25
resip::Poll::wait
const std::vector< Poll::FDEntry * > & wait(int timeoutMilliSeconds)
defined(RESIP_POLL_EXTERN) } {
resip::Poll::Poll
Poll()
Definition
Poll.cxx:201
resip::Poll::~Poll
~Poll()
Definition
Poll.cxx:206
resip::Poll::findFDInWaitResult
static int findFDInWaitResult(int fd, const std::vector< Poll::FDEntry * > &waitResult)
Definition
Poll.cxx:179
resip
dcm! – add UnusedChecking(_enum) below;
Definition
AbstractFifo.hxx:16
list
void list()
Definition
userAdmin.cxx:66
rutil
Poll.hxx
Generated by
1.9.8