Example usage for io.netty.channel DefaultEventLoopGroup DefaultEventLoopGroup

List of usage examples for io.netty.channel DefaultEventLoopGroup DefaultEventLoopGroup

Introduction

In this page you can find the example usage for io.netty.channel DefaultEventLoopGroup DefaultEventLoopGroup.

Prototype

public DefaultEventLoopGroup(int nThreads, Executor executor) 

Source Link

Document

Create a new instance

Usage

From source file:dorkbox.network.connection.Shutdownable.java

License:Apache License

/**
 * Creates a new event loop based on the specified configuration
 *
 * @param connectionType LOCAL, NIO, EPOLL, etc...
 * @param threadCount number of threads for the event loop
 *
 * @return a new event loop group based on the specified parameters
 */// www  . ja v  a 2s. c om
protected EventLoopGroup newEventLoop(final ConnectionType connectionType, final int threadCount,
        final String threadName) {
    NamedThreadFactory threadFactory = new NamedThreadFactory(threadName, threadGroup);

    EventLoopGroup group;

    switch (connectionType) {
    case LOCAL:
        group = new DefaultEventLoopGroup(threadCount, threadFactory);
        break;
    case OIO:
        group = new OioEventLoopGroup(threadCount, threadFactory);
        break;
    case NIO:
        group = new NioEventLoopGroup(threadCount, threadFactory);
        break;
    case EPOLL:
        group = new EpollEventLoopGroup(threadCount, threadFactory);
        break;
    case KQUEUE:
        group = new KQueueEventLoopGroup(threadCount, threadFactory);
        break;

    default:
        group = new DefaultEventLoopGroup(threadCount, threadFactory);
        break;
    }

    manageForShutdown(group);
    return group;
}