changeset 942:c157a786ed0b

remove Timeout.Task
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 11 Oct 2016 00:41:39 -0600
parents c948f674a2d5
children 96f60ce98949
files src/org/eclipse/jetty/io/nio/SelectorManager.java src/org/eclipse/jetty/util/thread/Timeout.java
diffstat 2 files changed, 0 insertions(+), 116 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/nio/SelectorManager.java	Tue Oct 11 00:34:19 2016 -0600
+++ b/src/org/eclipse/jetty/io/nio/SelectorManager.java	Tue Oct 11 00:41:39 2016 -0600
@@ -47,7 +47,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.eclipse.jetty.util.thread.Timeout;
-import org.eclipse.jetty.util.thread.Timeout.Task;
 
 
 /* ------------------------------------------------------------ */
@@ -498,11 +497,8 @@
 
 					// workout how long to wait in select
 					_timeout.setNow(now);
-					long to_next_timeout=_timeout.getTimeToNext();
 
 					long wait = _changes.size()==0?__IDLE_TICK:0L;
-					if (wait > 0 && to_next_timeout >= 0 && wait > to_next_timeout)
-						wait = to_next_timeout;
 
 					// If we should wait with a select
 					if (wait>0)
@@ -631,13 +627,6 @@
 
 				now=System.currentTimeMillis();
 				_timeout.setNow(now);
-				Task task = _timeout.expired();
-				while (task!=null)
-				{
-					if (task instanceof Runnable)
-						execute((Runnable)task);
-					task = _timeout.expired();
-				}
 
 				// Idle tick
 				if (now-_idleTick>__IDLE_TICK)
@@ -814,8 +803,6 @@
 					}
 				}
 
-
-				_timeout.cancelAll();
 				try
 				{
 					selector=_selector;
--- a/src/org/eclipse/jetty/util/thread/Timeout.java	Tue Oct 11 00:34:19 2016 -0600
+++ b/src/org/eclipse/jetty/util/thread/Timeout.java	Tue Oct 11 00:41:39 2016 -0600
@@ -37,13 +37,11 @@
 	private Object _lock;
 	private long _duration;
 	private volatile long _now=System.currentTimeMillis();
-	private Task _head=new Task();
 
 	/* ------------------------------------------------------------ */
 	public Timeout(Object lock)
 	{
 		_lock=lock;
-		_head._timeout=this;
 	}
 
 	/* ------------------------------------------------------------ */
@@ -70,114 +68,13 @@
 		return _now=System.currentTimeMillis();
 	}
 	
-	/* ------------------------------------------------------------ */
 	public long getNow()
 	{
 		return _now;
 	}
 
-	/* ------------------------------------------------------------ */
 	public void setNow(long now)
 	{
 		_now=now;
 	}
-
-	/* ------------------------------------------------------------ */
-	/** Get an expired tasks.
-	 * This is called instead of {@link #tick()} to obtain the next
-	 * expired Task, but without calling it's {@link Task#expire()} or
-	 * {@link Task#expired()} methods.
-	 * 
-	 * @return the next expired task or null.
-	 */
-
-	public Task expired()
-	{
-		synchronized (_lock)
-		{
-			long _expiry = _now-_duration;
-			if (_head._next!=_head)
-			{
-				Task task = _head._next;
-				if (task._timestamp>_expiry)
-					return null;
-
-				task.unlink();
-				task._expired=true;
-				return task;
-			}
-			return null;
-		}
-	}
-
-	public void cancelAll()
-	{
-		synchronized (_lock)
-		{
-			_head._next=_head._prev=_head;
-		}
-	}
-
-	public long getTimeToNext()
-	{
-		synchronized (_lock)
-		{
-			if (_head._next==_head)
-				return -1;
-			long to_next = _duration+_head._next._timestamp-_now;
-			return to_next<0?0:to_next;
-		}
-	}
-
-	@Override
-	public String toString()
-	{
-		StringBuffer buf = new StringBuffer();
-		buf.append(super.toString());
-		
-		Task task = _head._next;
-		while (task!=_head)
-		{
-			buf.append("-->");
-			buf.append(task);
-			task=task._next;
-		}
-		
-		return buf.toString();
-	}
-
-	/* ------------------------------------------------------------ */
-	/* ------------------------------------------------------------ */
-	/* ------------------------------------------------------------ */
-	/* ------------------------------------------------------------ */
-	/** Task.
-	 * The base class for scheduled timeouts.  This class should be
-	 * extended to implement the expire() method, which is called if the
-	 * timeout expires.
-	 * 
-	 * 
-	 *
-	 */
-	public static class Task
-	{
-		Task _next;
-		Task _prev;
-		Timeout _timeout;
-		long _timestamp=0;
-		boolean _expired=false;
-
-		protected Task()
-		{
-			_next=_prev=this;
-		}
-
-		private void unlink()
-		{
-			_next._prev=_prev;
-			_prev._next=_next;
-			_next=_prev=this;
-			_expired=false;
-		}
-	}
-
 }