EventLoopGroup cacheNativeClientLoops() { EventLoopGroup eventLoopGroup = cacheNativeClientLoops.get(); if (null == eventLoopGroup) { EventLoopGroup newEventLoopGroup = LoopResources.colocate(cacheNativeServerLoops()); if (!cacheNativeClientLoops.compareAndSet(null, newEventLoopGroup)) { // Do not shutdown newEventLoopGroup as this will shutdown the server loops } eventLoopGroup = cacheNativeClientLoops(); } return eventLoopGroup; }
EventLoopGroup cacheNativeClientLoops() { EventLoopGroup eventLoopGroup = cacheNativeClientLoops.get(); if (null == eventLoopGroup) { EventLoopGroup newEventLoopGroup = LoopResources.colocate(cacheNativeServerLoops()); if (!cacheNativeClientLoops.compareAndSet(null, newEventLoopGroup)) { // Do not shutdown newEventLoopGroup as this will shutdown the server loops } eventLoopGroup = cacheNativeClientLoops(); } return eventLoopGroup; }
@Override public EventLoopGroup onServer(boolean useNative) { if (useNative && preferNative()) { return cacheNativeServerLoops(); } return cacheNioServerLoops(); }
@Override public EventLoopGroup onServer(boolean useNative) { if (useNative && preferNative()) { return cacheNativeServerLoops(); } return cacheNioServerLoops(); }
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; }