Example usage for io.netty.channel EventLoopGroup iterator

List of usage examples for io.netty.channel EventLoopGroup iterator

Introduction

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

Prototype

@Override
    Iterator<EventExecutor> iterator();

Source Link

Usage

From source file:io.hekate.network.netty.NettyServerClient.java

License:Apache License

private EventLoop mapToThread(int affinity, NettyServerHandler handler) {
    EventLoopGroup group;

    // Check if a dedicated thread pool is defined for this protocol.
    if (handler.config().getEventLoop() == null) {
        // Use core thread pool.
        group = eventLoopGroup;/* w w w .  j  a  va2  s . c  om*/
    } else {
        // Use dedicated thread pool.
        group = handler.config().getEventLoop();
    }

    List<EventLoop> eventLoops = new ArrayList<>();

    // Assumes that the same group always returns its event loops in the same order.
    for (Iterator<EventExecutor> it = group.iterator(); it.hasNext();) {
        eventLoops.add((EventLoop) it.next());
    }

    return eventLoops.get(Utils.mod(affinity, eventLoops.size()));
}