From 4d0621855a40368052ecb9238c206d03d3067d25 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 9 Aug 2013 11:44:41 +0200 Subject: [PATCH] Remove unused package private method and so remove some complexity --- .../netty/channel/nio/AbstractNioChannel.java | 3 -- .../io/netty/channel/nio/NioEventLoop.java | 49 +------------------ 2 files changed, 2 insertions(+), 50 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java b/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java index 43b39982f6..b2852d8446 100644 --- a/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java +++ b/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java @@ -32,8 +32,6 @@ import java.net.SocketAddress; import java.nio.channels.CancelledKeyException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -49,7 +47,6 @@ public abstract class AbstractNioChannel extends AbstractChannel { protected final int readInterestOp; private volatile SelectionKey selectionKey; private volatile boolean inputShutdown; - final Queue> writableTasks = new ConcurrentLinkedQueue>(); /** * The future of the current connection attempt. If not null, subsequent diff --git a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java index 78dc9876e9..dfb76dd1f6 100644 --- a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java +++ b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java @@ -194,24 +194,6 @@ public final class NioEventLoop extends SingleThreadEventLoop { } } - void executeWhenWritable(AbstractNioChannel channel, NioTask task) { - if (channel == null) { - throw new NullPointerException("channel"); - } - - if (isShutdown()) { - throw new IllegalStateException("event loop shut down"); - } - - SelectionKey key = channel.selectionKey(); - channel.writableTasks.offer(task); - - int interestOps = key.interestOps(); - if ((interestOps & SelectionKey.OP_WRITE) == 0) { - key.interestOps(interestOps | SelectionKey.OP_WRITE); - } - } - /** * Returns the percentage of the desired amount of time spent for I/O in the event loop. */ @@ -501,7 +483,8 @@ public final class NioEventLoop extends SingleThreadEventLoop { } } if ((readyOps & SelectionKey.OP_WRITE) != 0) { - processWritable(ch); + // Call forceFlush which will also take care of clear the OP_WRITE once there is nothing left to write + ch.unsafe().forceFlush(); } if ((readyOps & SelectionKey.OP_CONNECT) != 0) { // remove OP_CONNECT as otherwise Selector.select(..) will always return without blocking @@ -513,37 +496,10 @@ public final class NioEventLoop extends SingleThreadEventLoop { unsafe.finishConnect(); } } catch (CancelledKeyException e) { - if (readyOps != -1 && (readyOps & SelectionKey.OP_WRITE) != 0) { - unregisterWritableTasks(ch); - } unsafe.close(unsafe.voidPromise()); } } - private static void processWritable(AbstractNioChannel ch) { - NioTask task; - for (;;) { - task = ch.writableTasks.poll(); - if (task == null) { break; } - processSelectedKey(ch.selectionKey(), task); - } - - // Call forceFlush which will also take care of clear the OP_WRITE once there is nothing left to write - ch.unsafe().forceFlush(); - } - - private static void unregisterWritableTasks(AbstractNioChannel ch) { - NioTask task; - for (;;) { - task = ch.writableTasks.poll(); - if (task == null) { - break; - } else { - invokeChannelUnregistered(task, ch.selectionKey(), null); - } - } - } - private static void processSelectedKey(SelectionKey k, NioTask task) { int state = 0; try { @@ -585,7 +541,6 @@ public final class NioEventLoop extends SingleThreadEventLoop { } for (AbstractNioChannel ch: channels) { - unregisterWritableTasks(ch); ch.unsafe().close(ch.unsafe().voidPromise()); } }