Cache flush(..) tasks which are used when executing with different EventExecutor to lower GC pressure
This commit is contained in:
parent
aa64c13bb8
commit
43f12569aa
@ -43,6 +43,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
// Lazily instantiated tasks used to trigger events to a handler with different executor.
|
// Lazily instantiated tasks used to trigger events to a handler with different executor.
|
||||||
private Runnable invokeChannelReadCompleteTask;
|
private Runnable invokeChannelReadCompleteTask;
|
||||||
private Runnable invokeRead0Task;
|
private Runnable invokeRead0Task;
|
||||||
|
private Runnable invokeFlush0Task;
|
||||||
private Runnable invokeChannelWritableStateChangedTask;
|
private Runnable invokeChannelWritableStateChangedTask;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -711,12 +712,16 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
if (executor.inEventLoop()) {
|
if (executor.inEventLoop()) {
|
||||||
invokeFlush0();
|
invokeFlush0();
|
||||||
} else {
|
} else {
|
||||||
executor.execute(new Runnable() {
|
Runnable task = invokeFlush0Task;
|
||||||
@Override
|
if (task == null) {
|
||||||
public void run() {
|
invokeFlush0Task = task = new Runnable() {
|
||||||
invokeFlush0();
|
@Override
|
||||||
}
|
public void run() {
|
||||||
});
|
invokeFlush0();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
executor.execute(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user