/** * Callback for server channel factory selection. * * @param group the source {@link EventLoopGroup} to assign a loop from * * @return a {@link Class} target for the underlying {@link ServerChannel} factory */ default Class<? extends ServerChannel> onServerChannel(EventLoopGroup group) { return preferNative() ? DefaultLoopNativeDetector.getInstance().getServerChannel(group) : NioServerSocketChannel.class; }
/** * Callback for client or generic channel factory selection. * * @param group the source {@link EventLoopGroup} to assign a loop from * * @return a {@link Class} target for the underlying {@link Channel} factory */ default Class<? extends Channel> onChannel(EventLoopGroup group) { return preferNative() ? DefaultLoopNativeDetector.getInstance().getChannel(group) : NioSocketChannel.class; }
/** * Callback for UDP channel factory selection. * * @param group the source {@link EventLoopGroup} to assign a loop from * * @return a {@link Class} target for the underlying {@link Channel} factory */ default Class<? extends DatagramChannel> onDatagramChannel(EventLoopGroup group) { return preferNative() ? DefaultLoopNativeDetector.getInstance().getDatagramChannel(group) : NioDatagramChannel.class; }
/** * Callback for client or generic channel factory selection. * * @param group the source {@link EventLoopGroup} to assign a loop from * * @return a {@link Class} target for the underlying {@link Channel} factory */ default Class<? extends Channel> onChannel(EventLoopGroup group) { return preferNative() ? DefaultLoopNativeDetector.getInstance().getChannel(group) : NioSocketChannel.class; }
/** * Callback for UDP channel factory selection. * * @param group the source {@link EventLoopGroup} to assign a loop from * * @return a {@link Class} target for the underlying {@link Channel} factory */ default Class<? extends DatagramChannel> onDatagramChannel(EventLoopGroup group) { return preferNative() ? DefaultLoopNativeDetector.getInstance().getDatagramChannel(group) : NioDatagramChannel.class; }
/** * Callback for server channel factory selection. * * @param group the source {@link EventLoopGroup} to assign a loop from * * @return a {@link Class} target for the underlying {@link ServerChannel} factory */ default Class<? extends ServerChannel> onServerChannel(EventLoopGroup group) { return preferNative() ? DefaultLoopNativeDetector.getInstance().getServerChannel(group) : NioServerSocketChannel.class; }
EventLoopGroup cacheNativeServerLoops() { EventLoopGroup eventLoopGroup = cacheNativeServerLoops.get(); if (null == eventLoopGroup) { DefaultLoop defaultLoop = DefaultLoopNativeDetector.getInstance(); EventLoopGroup newEventLoopGroup = defaultLoop.newEventLoopGroup( workerCount, threadFactory(this, defaultLoop.getName())); if (!cacheNativeServerLoops.compareAndSet(null, newEventLoopGroup)) { newEventLoopGroup.shutdownGracefully(); } eventLoopGroup = cacheNativeServerLoops(); } return eventLoopGroup; }
EventLoopGroup cacheNativeServerLoops() { EventLoopGroup eventLoopGroup = cacheNativeServerLoops.get(); if (null == eventLoopGroup) { DefaultLoop defaultLoop = DefaultLoopNativeDetector.getInstance(); EventLoopGroup newEventLoopGroup = defaultLoop.newEventLoopGroup( workerCount, threadFactory(this, defaultLoop.getName())); if (!cacheNativeServerLoops.compareAndSet(null, newEventLoopGroup)) { newEventLoopGroup.shutdownGracefully(); } eventLoopGroup = cacheNativeServerLoops(); } return eventLoopGroup; }
EventLoopGroup cacheNativeSelectLoops() { if (cacheNativeSelectLoops == cacheNativeServerLoops) { return cacheNativeServerLoops(); } EventLoopGroup eventLoopGroup = cacheNativeSelectLoops.get(); if (null == eventLoopGroup) { DefaultLoop defaultLoop = DefaultLoopNativeDetector.getInstance(); EventLoopGroup newEventLoopGroup = defaultLoop.newEventLoopGroup( selectCount, threadFactory(this, "select-" + defaultLoop.getName())); if (!cacheNativeSelectLoops.compareAndSet(null, newEventLoopGroup)) { newEventLoopGroup.shutdownGracefully(); } eventLoopGroup = cacheNativeSelectLoops(); } return eventLoopGroup; }
EventLoopGroup cacheNativeSelectLoops() { if (cacheNativeSelectLoops == cacheNativeServerLoops) { return cacheNativeServerLoops(); } EventLoopGroup eventLoopGroup = cacheNativeSelectLoops.get(); if (null == eventLoopGroup) { DefaultLoop defaultLoop = DefaultLoopNativeDetector.getInstance(); EventLoopGroup newEventLoopGroup = defaultLoop.newEventLoopGroup( selectCount, threadFactory(this, "select-" + defaultLoop.getName())); if (!cacheNativeSelectLoops.compareAndSet(null, newEventLoopGroup)) { newEventLoopGroup.shutdownGracefully(); } eventLoopGroup = cacheNativeSelectLoops(); } return eventLoopGroup; }