Remove unused package private method and so remove some complexity

This commit is contained in:
Norman Maurer 2013-08-09 11:44:41 +02:00
parent 26ddf0849f
commit 4d0621855a
2 changed files with 2 additions and 50 deletions

View File

@ -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<NioTask<SelectableChannel>> writableTasks = new ConcurrentLinkedQueue<NioTask<SelectableChannel>>();
/**
* The future of the current connection attempt. If not null, subsequent

View File

@ -194,24 +194,6 @@ public final class NioEventLoop extends SingleThreadEventLoop {
}
}
void executeWhenWritable(AbstractNioChannel channel, NioTask<SelectableChannel> 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<SelectableChannel> 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<SelectableChannel> task;
for (;;) {
task = ch.writableTasks.poll();
if (task == null) {
break;
} else {
invokeChannelUnregistered(task, ch.selectionKey(), null);
}
}
}
private static void processSelectedKey(SelectionKey k, NioTask<SelectableChannel> 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());
}
}