Mercurial Hosting > luan
diff src/org/eclipse/jetty/io/nio/SelectorManager.java @ 914:54308d65265a
simplify SelectorManager
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 09 Oct 2016 01:22:55 -0600 |
parents | 6b210bb66c63 |
children | b77d631b9e28 |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/nio/SelectorManager.java Sat Oct 08 23:57:11 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SelectorManager.java Sun Oct 09 01:22:55 2016 -0600 @@ -66,13 +66,10 @@ private static final int __IDLE_TICK=Integer.getInteger("org.eclipse.jetty.io.nio.IDLE_TICK",400).intValue(); private int _maxIdleTime; - private int _lowResourcesMaxIdleTime; private long _lowResourcesConnections; private SelectSet[] _selectSet; private int _selectSets=1; private volatile int _set=0; - private boolean _deferringInterestedOps0=true; - private int _selectorPriorityDelta=0; /* ------------------------------------------------------------ */ /** @@ -186,24 +183,6 @@ set.wakeup(); } - /* ------------------------------------------------------------ */ - /** - * @return delta The value to add to the selector thread priority. - */ - public int getSelectorPriorityDelta() - { - return _selectorPriorityDelta; - } - - /* ------------------------------------------------------------ */ - /** Set the selector thread priorty delta. - * @param delta The value to add to the selector thread priority. - */ - public void setSelectorPriorityDelta(int delta) - { - _selectorPriorityDelta=delta; - } - /* ------------------------------------------------------------ */ /** @@ -226,27 +205,7 @@ _lowResourcesConnections=(lowResourcesConnections+_selectSets-1)/_selectSets; } - /* ------------------------------------------------------------ */ - /** - * @return the lowResourcesMaxIdleTime - */ - public long getLowResourcesMaxIdleTime() - { - return _lowResourcesMaxIdleTime; - } - /* ------------------------------------------------------------ */ - /** - * @param lowResourcesMaxIdleTime the period in ms that a connection is allowed to be idle when this SelectSet has more connections than {@link #getLowResourcesConnections()} - * @see #setMaxIdleTime(long) - */ - public void setLowResourcesMaxIdleTime(long lowResourcesMaxIdleTime) - { - _lowResourcesMaxIdleTime=(int)lowResourcesMaxIdleTime; - } - - - /* ------------------------------------------------------------------------------- */ public abstract void execute(Runnable task); /* ------------------------------------------------------------ */ @@ -271,7 +230,6 @@ public void run() { String name=Thread.currentThread().getName(); - int priority=Thread.currentThread().getPriority(); try { SelectSet[] sets=_selectSet; @@ -280,8 +238,6 @@ SelectSet set=sets[id]; Thread.currentThread().setName(name+" Selector"+id); - if (getSelectorPriorityDelta()!=0) - Thread.currentThread().setPriority(Thread.currentThread().getPriority()+getSelectorPriorityDelta()); LOG.debug("Starting {} on {}",Thread.currentThread(),this); while (isRunning()) { @@ -303,8 +259,6 @@ { LOG.debug("Stopped {} on {}",Thread.currentThread(),this); Thread.currentThread().setName(name); - if (getSelectorPriorityDelta()!=0) - Thread.currentThread().setPriority(priority); } } @@ -336,15 +290,6 @@ */ protected abstract void endPointClosed(SelectChannelEndPoint endpoint); - /* ------------------------------------------------------------ */ - /** - * @param endpoint - */ - protected abstract void endPointOpened(SelectChannelEndPoint endpoint); - - /* ------------------------------------------------------------ */ - protected abstract void endPointUpgraded(ConnectedEndPoint endpoint,Connection oldConnection); - /* ------------------------------------------------------------------------------- */ public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment); @@ -700,7 +645,7 @@ _idleTick=now; final long idle_now=((_lowResourcesConnections>0 && selector.keys().size()>_lowResourcesConnections)) - ?(now+_maxIdleTime-_lowResourcesMaxIdleTime) + ?(now+_maxIdleTime) :now; execute(new Runnable() @@ -744,7 +689,6 @@ } - /* ------------------------------------------------------------ */ private void renewSelector() { try @@ -778,13 +722,11 @@ } } - /* ------------------------------------------------------------ */ public SelectorManager getManager() { return SelectorManager.this; } - /* ------------------------------------------------------------ */ public long getNow() { return _timeout.getNow(); @@ -804,13 +746,11 @@ _timeout.schedule(task, timeoutMs); } - /* ------------------------------------------------------------ */ public void cancelTimeout(Timeout.Task task) { task.cancel(); } - /* ------------------------------------------------------------ */ public void wakeup() { try @@ -833,17 +773,14 @@ } } - /* ------------------------------------------------------------ */ private SelectChannelEndPoint createEndPoint(SocketChannel channel, SelectionKey sKey) throws IOException { SelectChannelEndPoint endp = newEndPoint(channel,this,sKey); LOG.debug("created {}",endp); - endPointOpened(endp); _endPoints.put(endp,this); return endp; } - /* ------------------------------------------------------------ */ public void destroyEndPoint(SelectChannelEndPoint endp) { LOG.debug("destroyEndPoint {}",endp); @@ -851,13 +788,11 @@ endPointClosed(endp); } - /* ------------------------------------------------------------ */ Selector getSelector() { return _selector; } - /* ------------------------------------------------------------ */ void stop() throws Exception { // Spin for a while waiting for selector to complete @@ -914,13 +849,11 @@ } } - /* ------------------------------------------------------------ */ public String dump() { return AggregateLifeCycle.dump(this); } - /* ------------------------------------------------------------ */ public void dump(Appendable out, String indent) throws IOException { out.append(String.valueOf(this)).append(" id=").append(String.valueOf(_setID)).append("\n"); @@ -969,7 +902,6 @@ } } - /* ------------------------------------------------------------ */ public void dumpKeyState(List<Object> dumpto) { Selector selector=_selector; @@ -984,7 +916,6 @@ } } - /* ------------------------------------------------------------ */ public String toString() { Selector selector=_selector; @@ -995,7 +926,6 @@ } } - /* ------------------------------------------------------------ */ private static class ChannelAndAttachment { final SelectableChannel _channel; @@ -1009,22 +939,7 @@ } } - /* ------------------------------------------------------------ */ - public boolean isDeferringInterestedOps0() - { - return _deferringInterestedOps0; - } - /* ------------------------------------------------------------ */ - public void setDeferringInterestedOps0(boolean deferringInterestedOps0) - { - _deferringInterestedOps0 = deferringInterestedOps0; - } - - - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ private interface ChangeTask extends Runnable {}