Unify {Epoll,KQueue}EventLoopGroup initialization.
Motivation: `Epoll.ensureAvailability()` is called multiple times, once in static initialization and in a couple of the constructors. This is redundant and confusing to read. Modifications: Move `Epoll.ensureAvailability()` call into an instance initializer and remove all other references. This ensures that every EELG checks availability, while still delaying the check until construction. This pattern is used when there are multiple ctors, as in this class. Result: Easier to read code.
This commit is contained in:
parent
452fd36240
commit
d8f4547f5c
@ -33,8 +33,8 @@ import java.util.concurrent.ThreadFactory;
|
||||
* it only works on linux.
|
||||
*/
|
||||
public final class EpollEventLoopGroup extends MultithreadEventLoopGroup {
|
||||
static {
|
||||
// Ensure JNI is initialized by the time this class is loaded by this time!
|
||||
{
|
||||
// Ensure JNI is initialized by the time this class is loaded.
|
||||
Epoll.ensureAvailability();
|
||||
}
|
||||
|
||||
@ -102,25 +102,21 @@ public final class EpollEventLoopGroup extends MultithreadEventLoopGroup {
|
||||
public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, int maxEventsAtOnce,
|
||||
SelectStrategyFactory selectStrategyFactory) {
|
||||
super(nThreads, threadFactory, maxEventsAtOnce, selectStrategyFactory, RejectedExecutionHandlers.reject());
|
||||
Epoll.ensureAvailability();
|
||||
}
|
||||
|
||||
public EpollEventLoopGroup(int nThreads, Executor executor, SelectStrategyFactory selectStrategyFactory) {
|
||||
super(nThreads, executor, 0, selectStrategyFactory, RejectedExecutionHandlers.reject());
|
||||
Epoll.ensureAvailability();
|
||||
}
|
||||
|
||||
public EpollEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory,
|
||||
SelectStrategyFactory selectStrategyFactory) {
|
||||
super(nThreads, executor, chooserFactory, 0, selectStrategyFactory, RejectedExecutionHandlers.reject());
|
||||
Epoll.ensureAvailability();
|
||||
}
|
||||
|
||||
public EpollEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory,
|
||||
SelectStrategyFactory selectStrategyFactory,
|
||||
RejectedExecutionHandler rejectedExecutionHandler) {
|
||||
super(nThreads, executor, chooserFactory, 0, selectStrategyFactory, rejectedExecutionHandler);
|
||||
Epoll.ensureAvailability();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import java.util.concurrent.ThreadFactory;
|
||||
|
||||
@UnstableApi
|
||||
public final class KQueueEventLoopGroup extends MultithreadEventLoopGroup {
|
||||
static {
|
||||
{
|
||||
// Ensure JNI is initialized by the time this class is loaded by this time!
|
||||
KQueue.ensureAvailability();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user