Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Side by Side Diff: net/third_party/udt/src/epoll.h

Issue 6708091: Remove UDT. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/third_party/udt/src/core.cpp ('k') | net/third_party/udt/src/epoll.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*****************************************************************************
2 Copyright (c) 2001 - 2010, The Board of Trustees of the University of Illinois.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9 * Redistributions of source code must retain the above
10 copyright notice, this list of conditions and the
11 following disclaimer.
12
13 * Redistributions in binary form must reproduce the
14 above copyright notice, this list of conditions
15 and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17
18 * Neither the name of the University of Illinois
19 nor the names of its contributors may be used to
20 endorse or promote products derived from this
21 software without specific prior written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *****************************************************************************/
35
36 /*****************************************************************************
37 written by
38 Yunhong Gu, last updated 08/20/2010
39 *****************************************************************************/
40
41 #ifndef __UDT_EPOLL_H__
42 #define __UDT_EPOLL_H__
43
44
45 #include <map>
46 #include <set>
47 #include "udt.h"
48
49
50 struct CEPollDesc
51 {
52 int m_iID; // epoll ID
53 std::set<UDTSOCKET> m_sUDTSocks; // set of UDT sockets waiting for e vents
54
55 int m_iLocalID; // local system epoll ID
56 std::set<SYSSOCKET> m_sLocals; // set of local (non-UDT) descripto rs
57
58 std::set<UDTSOCKET> m_sUDTWrites; // UDT sockets ready for write
59 std::set<UDTSOCKET> m_sUDTReads; // UDT sockets ready for read
60 };
61
62 class CEPoll
63 {
64 friend class CUDT;
65
66 public:
67 CEPoll();
68 ~CEPoll();
69
70 public: // for CUDTUnited API
71
72 // Functionality:
73 // create a new EPoll.
74 // Parameters:
75 // None.
76 // Returned value:
77 // new EPoll ID if success, otherwise an error number.
78
79 int create();
80
81 // Functionality:
82 // add a UDT socket to an EPoll.
83 // Parameters:
84 // 0) [in] eid: EPoll ID.
85 // 1) [in] u: UDT Socket ID.
86 // 2) [in] events: events to watch.
87 // Returned value:
88 // 0 if success, otherwise an error number.
89
90 int add_usock(const int eid, const UDTSOCKET& u, const int* events = NULL);
91
92 // Functionality:
93 // add a system socket to an EPoll.
94 // Parameters:
95 // 0) [in] eid: EPoll ID.
96 // 1) [in] s: system Socket ID.
97 // 2) [in] events: events to watch.
98 // Returned value:
99 // 0 if success, otherwise an error number.
100
101 int add_ssock(const int eid, const SYSSOCKET& s, const int* events = NULL);
102
103 // Functionality:
104 // remove a UDT socket event from an EPoll; socket will be removed if n o events to watch
105 // Parameters:
106 // 0) [in] eid: EPoll ID.
107 // 1) [in] u: UDT socket ID.
108 // 2) [in] events: events to delete.
109 // Returned value:
110 // 0 if success, otherwise an error number.
111
112 int remove_usock(const int eid, const UDTSOCKET& u, const int* events = NULL) ;
113
114 // Functionality:
115 // remove a system socket event from an EPoll; socket will be removed i f no events to watch
116 // Parameters:
117 // 0) [in] eid: EPoll ID.
118 // 1) [in] s: system socket ID.
119 // 2) [in] events: events to delete.
120 // Returned value:
121 // 0 if success, otherwise an error number.
122
123 int remove_ssock(const int eid, const SYSSOCKET& s, const int* events = NULL) ;
124
125 // Functionality:
126 // wait for EPoll events or timeout.
127 // Parameters:
128 // 0) [in] eid: EPoll ID.
129 // 1) [out] readfds: UDT sockets available for reading.
130 // 2) [out] writefds: UDT sockets available for writing.
131 // 3) [in] msTimeOut: timeout threshold, in milliseconds.
132 // 4) [out] lrfds: system file descriptors for reading.
133 // 5) [out] lwfds: system file descriptors for writing.
134 // Returned value:
135 // number of sockets available for IO.
136
137 int wait(const int eid, std::set<UDTSOCKET>* readfds, std::set<UDTSOCKET>* wr itefds, int64_t msTimeOut, std::set<SYSSOCKET>* lrfds, std::set<SYSSOCKET>* lwfd s);
138
139 // Functionality:
140 // close and release an EPoll.
141 // Parameters:
142 // 0) [in] eid: EPoll ID.
143 // Returned value:
144 // 0 if success, otherwise an error number.
145
146 int release(const int eid);
147
148 public: // for CUDT to acknowledge IO status
149
150 // Functionality:
151 // set a UDT socket writable.
152 // Parameters:
153 // 0) [in] uid: UDT socket ID.
154 // 1) [in] eids: EPoll IDs to be set
155 // Returned value:
156 // 0 if success, otherwise an error number.
157
158 int enable_write(const UDTSOCKET& uid, std::set<int>& eids);
159
160 // Functionality:
161 // set a UDT socket readable.
162 // Parameters:
163 // 0) [in] uid: UDT socket ID.
164 // 1) [in] eids: EPoll IDs to be set
165 // Returned value:
166 // 0 if success, otherwise an error number.
167
168 int enable_read(const UDTSOCKET& uid, std::set<int>& eids);
169
170 // Functionality:
171 // reset a the writable status of a UDT socket.
172 // Parameters:
173 // 0) [in] uid: UDT socket ID.
174 // 1) [in] eids: EPoll IDs to be set
175 // Returned value:
176 // 0 if success, otherwise an error number.
177
178 int disable_write(const UDTSOCKET& uid, std::set<int>& eids);
179
180 // Functionality:
181 // reset a the readable status of a UDT socket.
182 // Parameters:
183 // 0) [in] uid: UDT socket ID.
184 // 1) [in] eids: EPoll IDs to be set
185 // Returned value:
186 // 0 if success, otherwise an error number.
187
188 int disable_read(const UDTSOCKET& uid, std::set<int>& eids);
189
190 private:
191 int m_iIDSeed; // seed to generate a new ID
192 pthread_mutex_t m_SeedLock;
193
194 std::map<int, CEPollDesc> m_mPolls; // all epolls
195 pthread_mutex_t m_EPollLock;
196 };
197
198
199 #endif
OLDNEW
« no previous file with comments | « net/third_party/udt/src/core.cpp ('k') | net/third_party/udt/src/epoll.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698