本文整理汇总了Java中io.netty.channel.Channel.eventLoop方法的典型用法代码示例。如果您正苦于以下问题:Java Channel.eventLoop方法的具体用法?Java Channel.eventLoop怎么用?Java Channel.eventLoop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.channel.Channel
的用法示例。
在下文中一共展示了Channel.eventLoop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: XrpcRequest
import io.netty.channel.Channel; //导入方法依赖的package包/类
public XrpcRequest(FullHttpRequest request, Map<String, String> groups, Channel channel) {
this.h1Request = request;
this.h2Headers = null;
this.groups = groups;
this.upstreamChannel = channel;
this.alloc = channel.alloc();
this.eventLoop = channel.eventLoop();
this.streamId = -1;
}
示例2: pauseReceiver
import io.netty.channel.Channel; //导入方法依赖的package包/类
private void pauseReceiver(boolean pause, Consumer<NetworkEndpoint<T>> callback) {
ChannelContext localCtx = this.channelCtx;
if (localCtx != null) {
if (debug) {
if (pause) {
log.debug("Pausing outbound receiver [to={}]", id());
} else {
log.debug("Resuming outbound receiver [to={}]", id());
}
}
Channel channel = localCtx.channel();
EventLoop eventLoop = channel.eventLoop();
if (eventLoop.inEventLoop()) {
channel.config().setAutoRead(!pause);
notifyOnReceivePause(pause, callback, channel);
} else {
eventLoop.execute(() -> {
channel.config().setAutoRead(!pause);
notifyOnReceivePause(pause, callback, channel);
});
}
} else if (callback != null) {
callback.accept(this);
}
}
示例3: pauseReceiver
import io.netty.channel.Channel; //导入方法依赖的package包/类
private void pauseReceiver(boolean pause, Consumer<NetworkEndpoint<Object>> callback) {
ChannelHandlerContext localCtx = this.handlerCtx;
if (localCtx != null) {
if (debug) {
if (pause) {
log.debug("Pausing inbound receiver [from={}, protocol={}]", address(), protocol);
} else {
log.debug("Resuming Pausing inbound receiver [from={}, protocol={}]", address(), protocol);
}
}
Channel channel = localCtx.channel();
EventLoop eventLoop = channel.eventLoop();
if (eventLoop.inEventLoop()) {
channel.config().setAutoRead(!pause);
notifyOnReceivePause(pause, callback, channel);
} else {
eventLoop.execute(() -> {
channel.config().setAutoRead(!pause);
notifyOnReceivePause(pause, callback, channel);
});
}
} else if (callback != null) {
callback.accept(this);
}
}
示例4: init
import io.netty.channel.Channel; //导入方法依赖的package包/类
private void init(Channel channel, HandshakeRequest request, HandlerRegistration handlerReg) {
NettyServerHandlerConfig<Object> cfg = handlerReg.config();
if (cfg.getLoggerCategory() != null) {
log = LoggerFactory.getLogger(cfg.getLoggerCategory());
debug = log.isDebugEnabled();
trace = log.isTraceEnabled();
}
if (debug) {
log.debug("Initialized connection [from={}, protocol={}]", address(), cfg.getProtocol());
}
this.eventLoop = channel.eventLoop();
this.serverHandler = cfg.getHandler();
this.handlerReg = handlerReg;
this.metrics = handlerReg.metrics();
this.codec = request.codec();
// Register this client.
handlerReg.add(this);
if (metrics != null) {
channel.pipeline().addFirst(new ChannelTrafficShapingHandler(0, 0, NettyClient.TRAFFIC_SHAPING_INTERVAL) {
@Override
protected void doAccounting(TrafficCounter counter) {
metrics.onBytesReceived(counter.lastReadBytes());
metrics.onBytesSent(counter.lastWrittenBytes());
}
});
metrics.onConnect();
}
// Accept handshake.
HandshakeAccept accepted = new HandshakeAccept(hbInterval, hbLossThreshold, hbDisabled);
channel.writeAndFlush(accepted).addListener(future -> {
if (channel.isOpen()) {
connectNotified = true;
// Notify on connect.
serverHandler.onConnect(request.payload(), this);
}
}
);
}