Mercurial Hosting > luan
changeset 943:96f60ce98949
remove Timeout
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 11 Oct 2016 02:02:48 -0600 |
parents | c157a786ed0b |
children | 1d24b6e422fa |
files | src/org/eclipse/jetty/io/nio/SelectorManager.java src/org/eclipse/jetty/util/thread/Timeout.java |
diffstat | 2 files changed, 14 insertions(+), 101 deletions(-) [+] |
line wrap: on
line diff
diff -r c157a786ed0b -r 96f60ce98949 src/org/eclipse/jetty/io/nio/SelectorManager.java --- 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()
diff -r c157a786ed0b -r 96f60ce98949 src/org/eclipse/jetty/util/thread/Timeout.java --- a/src/org/eclipse/jetty/util/thread/Timeout.java Tue Oct 11 00:41:39 2016 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. -// -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html -// -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php -// -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== -// - -package org.eclipse.jetty.util.thread; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/* ------------------------------------------------------------ */ -/** Timeout queue. - * This class implements a timeout queue for timers that are at least as likely to be cancelled as they are to expire. - * Unlike the util timeout class, the duration of the timeouts is shared by all scheduled tasks and if the duration - * is changed, this affects all scheduled tasks. - * <p> - * The nested class Task should be extended by users of this class to obtain call back notification of - * expires. - */ -public class Timeout -{ - private static final Logger LOG = LoggerFactory.getLogger(Timeout.class); - private Object _lock; - private long _duration; - private volatile long _now=System.currentTimeMillis(); - - /* ------------------------------------------------------------ */ - public Timeout(Object lock) - { - _lock=lock; - } - - /* ------------------------------------------------------------ */ - /** - * @return Returns the duration. - */ - public long getDuration() - { - return _duration; - } - - /* ------------------------------------------------------------ */ - /** - * @param duration The duration to set. - */ - public void setDuration(long duration) - { - _duration = duration; - } - - /* ------------------------------------------------------------ */ - public long setNow() - { - return _now=System.currentTimeMillis(); - } - - public long getNow() - { - return _now; - } - - public void setNow(long now) - { - _now=now; - } -}