Reduce the number of unnecessary Selector.wakeup() / Fix a bug where channelReadSuspended() generates garbage

This commit is contained in:
Trustin Lee 2013-02-09 01:05:33 +09:00
parent 801f563e80
commit a4c66dc282
2 changed files with 4 additions and 4 deletions

View File

@ -1023,7 +1023,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
public void fireChannelReadSuspended() {
final DefaultChannelHandlerContext next = findContextInbound();
EventExecutor executor = next.executor();
if (prev != null && executor.inEventLoop()) {
if (executor.inEventLoop()) {
next.invokeChannelReadSuspended();
} else {
Runnable task = next.invokeChannelReadSuspendedTask;

View File

@ -295,10 +295,10 @@ public final class NioEventLoop extends SingleThreadEventLoop {
cancelledKeys = 0;
runAllTasks();
processSelectedKeys();
selector = this.selector;
processSelectedKeys();
runAllTasks();
selector = this.selector;
if (isShutdown()) {
@ -502,7 +502,7 @@ public final class NioEventLoop extends SingleThreadEventLoop {
@Override
protected void wakeup(boolean inEventLoop) {
if (wakenUp.compareAndSet(false, true)) {
if (!inEventLoop && wakenUp.compareAndSet(false, true)) {
selector.wakeup();
}
}