EpollEventLoopGroup support Executor

Motivation:
NioEventLoopGroup supports constructors which take an executor but EpollEventLoopGroup does not. EPOLL should be consistent with NIO where ever possible.

Modifications:
- Add constructors to EpollEventLoopGroup which accept an Executor as a parameter

Result:
EpollEventLoopGroup is more consistent with NioEventLoopGroup
Fixes https://github.com/netty/netty/issues/5161
This commit is contained in:
Scott Mitchell 2016-04-19 10:02:01 -07:00
parent f94edd2e92
commit f8f1efc3ba

View File

@ -16,6 +16,7 @@
package io.netty.channel.epoll; package io.netty.channel.epoll;
import io.netty.channel.DefaultSelectStrategyFactory; import io.netty.channel.DefaultSelectStrategyFactory;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup; import io.netty.channel.EventLoopGroup;
import io.netty.channel.MultithreadEventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup;
import io.netty.channel.SelectStrategyFactory; import io.netty.channel.SelectStrategyFactory;
@ -48,7 +49,7 @@ public final class EpollEventLoopGroup extends MultithreadEventLoopGroup {
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public EpollEventLoopGroup(int nThreads, SelectStrategyFactory selectStrategyFactory) { public EpollEventLoopGroup(int nThreads, SelectStrategyFactory selectStrategyFactory) {
this(nThreads, null, selectStrategyFactory); this(nThreads, (ThreadFactory) null, selectStrategyFactory);
} }
/** /**
@ -59,6 +60,10 @@ public final class EpollEventLoopGroup extends MultithreadEventLoopGroup {
this(nThreads, threadFactory, 0); this(nThreads, threadFactory, 0);
} }
public EpollEventLoopGroup(int nThreads, Executor executor) {
this(nThreads, executor, DefaultSelectStrategyFactory.INSTANCE);
}
/** /**
* Create a new instance using the specified number of threads and the given {@link ThreadFactory}. * Create a new instance using the specified number of threads and the given {@link ThreadFactory}.
*/ */
@ -91,6 +96,10 @@ public final class EpollEventLoopGroup extends MultithreadEventLoopGroup {
super(nThreads, threadFactory, maxEventsAtOnce, selectStrategyFactory); super(nThreads, threadFactory, maxEventsAtOnce, selectStrategyFactory);
} }
public EpollEventLoopGroup(int nThreads, Executor executor, SelectStrategyFactory selectStrategyFactory) {
super(nThreads, executor, 0, selectStrategyFactory);
}
/** /**
* Sets the percentage of the desired amount of time spent for I/O in the child event loops. The default value is * Sets the percentage of the desired amount of time spent for I/O in the child event loops. The default value is
* {@code 50}, which means the event loop will try to spend the same amount of time for I/O as for non-I/O tasks. * {@code 50}, which means the event loop will try to spend the same amount of time for I/O as for non-I/O tasks.