Mercurial Hosting > luan
comparison src/org/eclipse/jetty/io/nio/SelectorManager.java @ 958:fc521d2f098e
simplify SelectorManager
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 13 Oct 2016 18:48:20 -0600 |
parents | d6b6d3e40161 |
children | 7b94f5b33c64 |
comparison
equal
deleted
inserted
replaced
957:d6b6d3e40161 | 958:fc521d2f098e |
---|---|
172 set.stop(); | 172 set.stop(); |
173 } | 173 } |
174 super.doStop(); | 174 super.doStop(); |
175 } | 175 } |
176 | 176 |
177 public abstract AsyncConnection newConnection(SocketChannel channel, SelectChannelEndPoint endpoint, Object attachment); | 177 public abstract AsyncConnection newConnection(SocketChannel channel, SelectChannelEndPoint endpoint); |
178 | 178 |
179 public String dump() | 179 public String dump() |
180 { | 180 { |
181 return AggregateLifeCycle.dump(this); | 181 return AggregateLifeCycle.dump(this); |
182 } | 182 } |
192 { | 192 { |
193 private volatile long _now = System.currentTimeMillis(); | 193 private volatile long _now = System.currentTimeMillis(); |
194 | 194 |
195 private final SaneSelector _selector; | 195 private final SaneSelector _selector; |
196 | 196 |
197 SelectSet() throws IOException | 197 private SelectSet() throws IOException |
198 { | 198 { |
199 _selector = new SaneSelector(); | 199 _selector = new SaneSelector(); |
200 } | 200 } |
201 | 201 |
202 private void addChange(SocketChannel channel) | 202 private void addChange(SocketChannel channel) |
203 { | 203 { |
204 try { | 204 try { |
205 //System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqqqq a"); | 205 //System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqqqq a"); |
206 // SelectionKey key = _selector.register(channel,SelectionKey.OP_READ,null); | 206 // SelectionKey key = _selector.register(channel,SelectionKey.OP_READ,null); |
207 SelectionKey key = _selector.register(channel,0,null); | 207 SelectionKey key = _selector.register(channel,0,null); |
208 SelectChannelEndPoint endpoint = createEndPoint(channel,key); | 208 |
209 SelectChannelEndPoint endpoint = new SelectChannelEndPoint(channel,this,key, _maxIdleTime); | |
210 endpoint.setConnection(newConnection(channel,endpoint)); | |
211 | |
209 key.attach(endpoint); | 212 key.attach(endpoint); |
210 key.interestOps(SelectionKey.OP_READ); | 213 key.interestOps(SelectionKey.OP_READ); |
211 _selector.update(); | 214 _selector.update(); |
212 //System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqqqq b"); | 215 //System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqqqq b"); |
213 endpoint.schedule(); | 216 endpoint.schedule(); |
285 public long getNow() | 288 public long getNow() |
286 { | 289 { |
287 return _now; | 290 return _now; |
288 } | 291 } |
289 | 292 |
290 private SelectChannelEndPoint createEndPoint(SocketChannel channel, SelectionKey sKey) throws IOException | |
291 { | |
292 SelectChannelEndPoint endp = new SelectChannelEndPoint(channel,this,sKey, _maxIdleTime); | |
293 endp.setConnection(getManager().newConnection(channel,endp, sKey.attachment())); | |
294 LOG.debug("created {}",endp); | |
295 return endp; | |
296 } | |
297 | |
298 public void destroyEndPoint(SelectChannelEndPoint endp) | 293 public void destroyEndPoint(SelectChannelEndPoint endp) |
299 { | 294 { |
300 LOG.debug("destroyEndPoint {}",endp); | 295 LOG.debug("destroyEndPoint {}",endp); |
301 endp.getConnection().onClose(); | 296 endp.getConnection().onClose(); |
302 } | 297 } |