Allow writing with void promise if IdleStateHandler is configured in pipeline.
Motivation: Allow writing with void promise if IdleStateHandler is configured in the pipeline for read timeout events. Modifications: Better performance. Result: No more ChannelFutureListeners are created if IdleStateHandler is only configured for read timeouts allowing for writing to the channel with void promise.
This commit is contained in:
parent
6703318010
commit
0decf2f647
@ -256,6 +256,8 @@ public class IdleStateHandler extends ChannelDuplexHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||||
|
// Allow writing with void promise if handler is only configured for read timeout events.
|
||||||
|
if (writerIdleTimeNanos > 0 || allIdleTimeNanos > 0) {
|
||||||
promise.addListener(new ChannelFutureListener() {
|
promise.addListener(new ChannelFutureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(ChannelFuture future) throws Exception {
|
public void operationComplete(ChannelFuture future) throws Exception {
|
||||||
@ -263,6 +265,7 @@ public class IdleStateHandler extends ChannelDuplexHandler {
|
|||||||
firstWriterIdleEvent = firstAllIdleEvent = true;
|
firstWriterIdleEvent = firstAllIdleEvent = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
ctx.write(msg, promise);
|
ctx.write(msg, promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user