EpollDatagramChannel avoid getOption

Motivation:
EpollDatagramChannel uses getOption in the isActive method. getOption is backed by a relatively large conditional if/else if block and this conditional checking can be avoided in the epoll transport.

Modifications:
- Add EpollDatagramChannelConfig#getActiveOnOpen and use this in EpollDatagramChannel

Result:
Conditional checking due to getOption is removed from EpollDatagramChannel.
This commit is contained in:
Scott Mitchell 2017-02-16 08:05:48 -08:00
parent 2dc9d119b1
commit 3b65e7ea28
2 changed files with 5 additions and 4 deletions

View File

@ -20,7 +20,6 @@ import io.netty.buffer.CompositeByteBuf;
import io.netty.channel.AddressedEnvelope; import io.netty.channel.AddressedEnvelope;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelMetadata; import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelOutboundBuffer; import io.netty.channel.ChannelOutboundBuffer;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise; import io.netty.channel.ChannelPromise;
@ -105,9 +104,7 @@ public final class EpollDatagramChannel extends AbstractEpollChannel implements
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean isActive() { public boolean isActive() {
return fd().isOpen() && return fd().isOpen() && (config.getActiveOnOpen() && isRegistered() || active);
(config.getOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION) && isRegistered()
|| active);
} }
@Override @Override

View File

@ -131,6 +131,10 @@ public final class EpollDatagramChannelConfig extends EpollChannelConfig impleme
this.activeOnOpen = activeOnOpen; this.activeOnOpen = activeOnOpen;
} }
boolean getActiveOnOpen() {
return activeOnOpen;
}
@Override @Override
public EpollDatagramChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator) { public EpollDatagramChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator) {
super.setMessageSizeEstimator(estimator); super.setMessageSizeEstimator(estimator);