Search in sources :

Example 1 with NamedThreadFactory

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;
    }
}
Also used : NamedThreadFactory(com.duangframework.server.utils.NamedThreadFactory) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Example 2 with NamedThreadFactory

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;
    }
}
Also used : NamedThreadFactory(com.duangframework.server.utils.NamedThreadFactory) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Aggregations

NamedThreadFactory (com.duangframework.server.utils.NamedThreadFactory)2 EpollEventLoopGroup (io.netty.channel.epoll.EpollEventLoopGroup)2 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2