Mercurial Hosting > luan
diff src/org/eclipse/jetty/io/nio/SelectorManager.java @ 943:96f60ce98949
remove Timeout
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 11 Oct 2016 02:02:48 -0600 |
parents | c157a786ed0b |
children | 1d24b6e422fa |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/nio/SelectorManager.java Tue Oct 11 00:41:39 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SelectorManager.java Tue Oct 11 02:02:48 2016 -0600 @@ -46,7 +46,6 @@ import org.eclipse.jetty.util.component.Dumpable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.eclipse.jetty.util.thread.Timeout; /* ------------------------------------------------------------ */ @@ -330,7 +329,7 @@ public class SelectSet implements Dumpable { private final int _setID; - private final Timeout _timeout; + private volatile long _now = System.currentTimeMillis(); private final ConcurrentLinkedQueue<Object> _changes = new ConcurrentLinkedQueue<Object>(); @@ -350,8 +349,6 @@ _setID=acceptorID; _idleTick = System.currentTimeMillis(); - _timeout = new Timeout(this); - _timeout.setDuration(0L); // create a selector; _selector = Selector.open(); @@ -476,7 +473,7 @@ // Do and instant select to see if any connections can be handled. int selected=selector.selectNow(); - long now=System.currentTimeMillis(); + _now = System.currentTimeMillis(); // if no immediate things to do if (selected==0 && selector.selectedKeys().isEmpty()) @@ -492,25 +489,22 @@ { LOG.trace("",e); } - now=System.currentTimeMillis(); + _now = System.currentTimeMillis(); } // workout how long to wait in select - _timeout.setNow(now); - long wait = _changes.size()==0?__IDLE_TICK:0L; // If we should wait with a select if (wait>0) { - long before=now; + long before = _now; selector.select(wait); - now = System.currentTimeMillis(); - _timeout.setNow(now); + _now = System.currentTimeMillis(); // If we are monitoring for busy selector // and this select did not wait more than 1ms - if (__MONITOR_PERIOD>0 && now-before <=1) + if (__MONITOR_PERIOD>0 && _now-before <=1) { // count this as a busy select and if there have been too many this monitor cycle if (++_busySelects>__MAX_SELECTS) @@ -625,17 +619,16 @@ // Everything always handled selector.selectedKeys().clear(); - now=System.currentTimeMillis(); - _timeout.setNow(now); + _now = System.currentTimeMillis(); // Idle tick - if (now-_idleTick>__IDLE_TICK) + if (_now-_idleTick>__IDLE_TICK) { - _idleTick=now; + _idleTick = _now; final long idle_now=((_lowResourcesConnections>0 && selector.keys().size()>_lowResourcesConnections)) - ?(now+_maxIdleTime) - :now; + ?(_now+_maxIdleTime) + :_now; execute(new Runnable() { @@ -652,11 +645,11 @@ } // Reset busy select monitor counts - if (__MONITOR_PERIOD>0 && now>_monitorNext) + if (__MONITOR_PERIOD>0 && _now>_monitorNext) { _busySelects=0; _pausing=false; - _monitorNext=now+__MONITOR_PERIOD; + _monitorNext=_now+__MONITOR_PERIOD; } } @@ -718,7 +711,7 @@ public long getNow() { - return _timeout.getNow(); + return _now; } public void wakeup()