diff src/org/eclipse/jetty/io/nio/SelectorManager.java @ 949:e9088af3787f

remove SelectSet._changes
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 11 Oct 2016 23:18:13 -0600
parents f5aefdc4a81a
children a778413aefc0
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/nio/SelectorManager.java	Tue Oct 11 22:16:29 2016 -0600
+++ b/src/org/eclipse/jetty/io/nio/SelectorManager.java	Tue Oct 11 23:18:13 2016 -0600
@@ -115,22 +115,6 @@
 	}
 
 	/* ------------------------------------------------------------ */
-	/** Register a {@link ServerSocketChannel}
-	 * @param acceptChannel
-	 */
-	public void register(ServerSocketChannel acceptChannel)
-	{
-		int s=_set++;
-		if (s<0)
-			s=-s;
-		s=s%_selectSets;
-		SelectSet set=_selectSet[s];
-		set.addChange(acceptChannel);
-		set.wakeup();
-	}
-
-
-	/* ------------------------------------------------------------ */
 	/**
 	 * @return the lowResourcesConnections
 	 */
@@ -250,8 +234,6 @@
 		private final int _setID;
 		private volatile long _now = System.currentTimeMillis();
 
-		private final ConcurrentLinkedQueue<Object> _changes = new ConcurrentLinkedQueue<Object>();
-
 		private volatile Selector _selector;
 
 		private volatile Thread _selecting;
@@ -273,11 +255,22 @@
 			_monitorNext=System.currentTimeMillis()+__MONITOR_PERIOD;
 		}
 
-		public void addChange(Object change)
+		private void addChange(SocketChannel channel)
 		{
-			_changes.add(change);
+			try {
+				SelectionKey key = channel.register(_selector,SelectionKey.OP_READ,null);
+				SelectChannelEndPoint endpoint = createEndPoint(channel,key);
+				key.attach(endpoint);
+				endpoint.schedule();
+			} catch(IOException e) {
+				LOG.warn("",e);
+				try {
+					channel.close();
+				} catch(IOException e2) {
+					LOG.warn("",e2);
+				}
+			}
 		}
-
 		/* ------------------------------------------------------------ */
 		/**
 		 * Select and dispatch tasks found from changes and the selector.
@@ -294,64 +287,6 @@
 				if (selector == null)
 					return;
 
-				// Make any key changes required
-				Object change;
-				int changes=_changes.size();
-				while (changes-->0 && (change=_changes.poll())!=null)
-				{
-					Channel ch=null;
-					SelectionKey key=null;
-
-					try
-					{
-						if (change instanceof EndPoint)
-						{
-							// Update the operations for a key.
-							SelectChannelEndPoint endpoint = (SelectChannelEndPoint)change;
-							ch=endpoint.getChannel();
-							endpoint.doUpdateKey();
-						}
-						else if (change instanceof SocketChannel)
-						{
-							// Newly registered channel
-							final SocketChannel channel=(SocketChannel)change;
-							ch=channel;
-							key = channel.register(selector,SelectionKey.OP_READ,null);
-							SelectChannelEndPoint endpoint = createEndPoint(channel,key);
-							key.attach(endpoint);
-							endpoint.schedule();
-						}
-						else if (change instanceof Runnable)
-						{
-							execute((Runnable)change);
-						}
-						else
-							throw new IllegalArgumentException(change.toString());
-					}
-					catch (CancelledKeyException e)
-					{
-						LOG.trace("",e);
-					}
-					catch (Throwable e)
-					{
-						if (isRunning())
-							LOG.warn("",e);
-						else
-							LOG.debug("",e);
-
-						try
-						{
-							if (ch!=null)
-								ch.close();
-						}
-						catch(IOException e2)
-						{
-							LOG.debug("",e2);
-						}
-					}
-				}
-
-
 				// Do and instant select to see if any connections can be handled.
 				int selected=selector.selectNow();
 
@@ -375,7 +310,7 @@
 					}
 
 					// workout how long to wait in select
-					long wait = _changes.size()==0?__IDLE_TICK:0L;
+					long wait = __IDLE_TICK;
 
 					// If we should wait with a select
 					if (wait>0)