use of com.duangframework.server.utils.NamedThreadFactory in project duangframework by tcrct.
the class EventLoopGroupFactory method builderBossLoopGroup.
public static EventLoopGroup builderBossLoopGroup() {
Executor executor = builderThreadPoolExecutor(ServerConfig.MAX_BOSS_EXECUTORS_NUMBER, ServerConfig.MAX_BOSS_EXECUTORS_NUMBER, ServerConfig.KEEP_ALIVETIME, TimeUnit.HOURS, new ArrayBlockingQueue<Runnable>(ServerConfig.MAX_BOSS_EXECUTORS_NUMBER), new NamedThreadFactory(ServerConfig.BOSSGROUP_POOLTHREAD_NAME));
if (NativeSupport.isSupportNative()) {
EpollEventLoopGroup bossLoopGroup = new EpollEventLoopGroup(ServerConfig.MAX_BOSS_EXECUTORS_NUMBER, executor);
bossLoopGroup.setIoRatio(ServerConfig.IO_RATIO_NUMBER);
return bossLoopGroup;
} else {
NioEventLoopGroup bossLoopGroup = new NioEventLoopGroup(ServerConfig.MAX_BOSS_EXECUTORS_NUMBER, executor);
bossLoopGroup.setIoRatio(ServerConfig.IO_RATIO_NUMBER);
return bossLoopGroup;
}
}
use of com.duangframework.server.utils.NamedThreadFactory in project duangframework by tcrct.
the class EventLoopGroupFactory method builderWorkerLoopGroup.
public static EventLoopGroup builderWorkerLoopGroup() {
int workerNum = Runtime.getRuntime().availableProcessors() << 1;
Executor executor = builderThreadPoolExecutor(workerNum, workerNum, ServerConfig.KEEP_ALIVETIME, TimeUnit.HOURS, new ArrayBlockingQueue<Runnable>(workerNum), new NamedThreadFactory(ServerConfig.WORKERGROUP_POOLTHREAD_NAME));
if (NativeSupport.isSupportNative()) {
EpollEventLoopGroup workerLoopGroup = new EpollEventLoopGroup(workerNum, executor);
workerLoopGroup.setIoRatio(ServerConfig.IO_RATIO_NUMBER);
return workerLoopGroup;
} else {
NioEventLoopGroup workerLoopGroup = new NioEventLoopGroup(workerNum, executor);
workerLoopGroup.setIoRatio(ServerConfig.IO_RATIO_NUMBER);
return workerLoopGroup;
}
}
Aggregations