diff --git a/microbench/src/main/java/io/netty/microbench/channel/EmbeddedChannelWriteReleaseHandlerContext.java b/microbench/src/main/java/io/netty/microbench/channel/EmbeddedChannelWriteReleaseHandlerContext.java index b8984ea488..9a74f98d97 100644 --- a/microbench/src/main/java/io/netty/microbench/channel/EmbeddedChannelWriteReleaseHandlerContext.java +++ b/microbench/src/main/java/io/netty/microbench/channel/EmbeddedChannelWriteReleaseHandlerContext.java @@ -20,9 +20,11 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelHandlerInvoker; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelProgressivePromise; import io.netty.channel.ChannelPromise; +import io.netty.channel.EventLoop; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.util.Attribute; import io.netty.util.AttributeKey; @@ -33,7 +35,7 @@ import java.net.SocketAddress; public abstract class EmbeddedChannelWriteReleaseHandlerContext implements ChannelHandlerContext { private static final String HANDLER_NAME = "microbench-delegator-ctx"; - private final EventExecutor executor; + private final EventLoop eventLoop; private final Channel channel; private final ByteBufAllocator alloc; private final ChannelHandler handler; @@ -48,7 +50,7 @@ public abstract class EmbeddedChannelWriteReleaseHandlerContext implements Chann this.alloc = checkNotNull(alloc, "alloc"); this.channel = checkNotNull(channel, "channel"); this.handler = checkNotNull(handler, "handler"); - this.executor = checkNotNull(channel.eventLoop(), "executor"); + this.eventLoop = checkNotNull(channel.eventLoop(), "eventLoop"); } protected abstract void handleException(Throwable t); @@ -70,7 +72,12 @@ public abstract class EmbeddedChannelWriteReleaseHandlerContext implements Chann @Override public EventExecutor executor() { - return executor; + return eventLoop; + } + + @Override + public ChannelHandlerInvoker invoker() { + return eventLoop.asInvoker(); } @Override diff --git a/transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java index f9e7b80286..f3b4b12c14 100644 --- a/transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java @@ -82,6 +82,7 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R return invoker().executor(); } + @Override public ChannelHandlerInvoker invoker() { if (invoker == null) { return channel().unsafe().invoker(); diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java index 7b8e7c4e33..0fdb8476ad 100644 --- a/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java @@ -136,6 +136,14 @@ public interface ChannelHandlerContext extends AttributeMap { */ EventExecutor executor(); + /** + * Returns the {@link ChannelHandlerInvoker} which is used to trigger an event for the associated + * {@link ChannelHandler}. Note that the methods in {@link ChannelHandlerInvoker} are not intended to be called + * by a user. Use this method only to obtain the reference to the {@link ChannelHandlerInvoker} + * (and not calling its methods) unless you know what you are doing. + */ + ChannelHandlerInvoker invoker(); + /** * The unique name of the {@link ChannelHandlerContext}.The name was used when then {@link ChannelHandler} * was added to the {@link ChannelPipeline}. This name can also be used to access the registered diff --git a/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java b/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java index 4abc488468..bf6d266b1d 100644 --- a/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java +++ b/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java @@ -372,6 +372,11 @@ public class CombinedChannelDuplexHandler