Reduce the number of unnecessary Selector.wakeup() / Fix a bug where channelReadSuspended() generates garbage
This commit is contained in:
parent
801f563e80
commit
a4c66dc282
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user