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() {
|
public void fireChannelReadSuspended() {
|
||||||
final DefaultChannelHandlerContext next = findContextInbound();
|
final DefaultChannelHandlerContext next = findContextInbound();
|
||||||
EventExecutor executor = next.executor();
|
EventExecutor executor = next.executor();
|
||||||
if (prev != null && executor.inEventLoop()) {
|
if (executor.inEventLoop()) {
|
||||||
next.invokeChannelReadSuspended();
|
next.invokeChannelReadSuspended();
|
||||||
} else {
|
} else {
|
||||||
Runnable task = next.invokeChannelReadSuspendedTask;
|
Runnable task = next.invokeChannelReadSuspendedTask;
|
||||||
|
@ -295,10 +295,10 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
|
|
||||||
cancelledKeys = 0;
|
cancelledKeys = 0;
|
||||||
|
|
||||||
runAllTasks();
|
processSelectedKeys();
|
||||||
selector = this.selector;
|
selector = this.selector;
|
||||||
|
|
||||||
processSelectedKeys();
|
runAllTasks();
|
||||||
selector = this.selector;
|
selector = this.selector;
|
||||||
|
|
||||||
if (isShutdown()) {
|
if (isShutdown()) {
|
||||||
@ -502,7 +502,7 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void wakeup(boolean inEventLoop) {
|
protected void wakeup(boolean inEventLoop) {
|
||||||
if (wakenUp.compareAndSet(false, true)) {
|
if (!inEventLoop && wakenUp.compareAndSet(false, true)) {
|
||||||
selector.wakeup();
|
selector.wakeup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user