2014-02-15 22:26:36 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2014 The Netty Project
|
|
|
|
*
|
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
package io.netty.channel.epoll;
|
|
|
|
|
|
|
|
import io.netty.channel.EventLoopGroup;
|
2019-01-23 08:32:05 +01:00
|
|
|
import io.netty.channel.DefaultSelectStrategyFactory;
|
2014-02-15 22:26:36 +01:00
|
|
|
import io.netty.channel.MultithreadEventLoopGroup;
|
2016-03-25 20:44:51 +01:00
|
|
|
import io.netty.channel.SelectStrategyFactory;
|
2014-02-15 22:26:36 +01:00
|
|
|
|
|
|
|
import java.util.concurrent.Executor;
|
|
|
|
import java.util.concurrent.ThreadFactory;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@link EventLoopGroup} which uses epoll under the covers. Because of this
|
|
|
|
* it only works on linux.
|
2019-01-23 08:32:05 +01:00
|
|
|
*
|
|
|
|
* @deprecated use {@link MultithreadEventLoopGroup} together with {@link EpollHandler}.
|
2014-02-15 22:26:36 +01:00
|
|
|
*/
|
2019-01-23 08:32:05 +01:00
|
|
|
@Deprecated
|
2014-02-15 22:26:36 +01:00
|
|
|
public final class EpollEventLoopGroup extends MultithreadEventLoopGroup {
|
2017-07-21 21:37:18 +02:00
|
|
|
{
|
|
|
|
// Ensure JNI is initialized by the time this class is loaded.
|
2017-01-19 17:31:34 +01:00
|
|
|
Epoll.ensureAvailability();
|
|
|
|
}
|
2014-02-15 22:26:36 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance using the default number of threads and the default {@link ThreadFactory}.
|
|
|
|
*/
|
|
|
|
public EpollEventLoopGroup() {
|
|
|
|
this(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance using the specified number of threads and the default {@link ThreadFactory}.
|
|
|
|
*/
|
|
|
|
public EpollEventLoopGroup(int nThreads) {
|
2016-03-25 20:44:51 +01:00
|
|
|
this(nThreads, (ThreadFactory) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance using the specified number of threads and the default {@link ThreadFactory}.
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public EpollEventLoopGroup(int nThreads, SelectStrategyFactory selectStrategyFactory) {
|
2016-04-19 19:02:01 +02:00
|
|
|
this(nThreads, (ThreadFactory) null, selectStrategyFactory);
|
2014-02-15 22:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance using the specified number of threads and the given {@link ThreadFactory}.
|
|
|
|
*/
|
2015-01-29 20:53:52 +01:00
|
|
|
@SuppressWarnings("deprecation")
|
2014-02-15 22:26:36 +01:00
|
|
|
public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory) {
|
2015-01-29 20:53:52 +01:00
|
|
|
this(nThreads, threadFactory, 0);
|
2014-02-15 22:26:36 +01:00
|
|
|
}
|
|
|
|
|
2016-04-19 19:02:01 +02:00
|
|
|
public EpollEventLoopGroup(int nThreads, Executor executor) {
|
|
|
|
this(nThreads, executor, DefaultSelectStrategyFactory.INSTANCE);
|
|
|
|
}
|
|
|
|
|
2016-03-25 20:44:51 +01:00
|
|
|
/**
|
|
|
|
* Create a new instance using the specified number of threads and the given {@link ThreadFactory}.
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, SelectStrategyFactory selectStrategyFactory) {
|
|
|
|
this(nThreads, threadFactory, 0, selectStrategyFactory);
|
|
|
|
}
|
|
|
|
|
2014-02-15 22:26:36 +01:00
|
|
|
/**
|
|
|
|
* Create a new instance using the specified number of threads, the given {@link ThreadFactory} and the given
|
|
|
|
* maximal amount of epoll events to handle per epollWait(...).
|
2015-01-29 20:53:52 +01:00
|
|
|
*
|
2016-03-25 20:44:51 +01:00
|
|
|
* @deprecated Use {@link #EpollEventLoopGroup(int)} or {@link #EpollEventLoopGroup(int, ThreadFactory)}
|
2014-02-15 22:26:36 +01:00
|
|
|
*/
|
2015-01-29 20:53:52 +01:00
|
|
|
@Deprecated
|
2014-02-15 22:26:36 +01:00
|
|
|
public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, int maxEventsAtOnce) {
|
2016-03-25 20:44:51 +01:00
|
|
|
this(nThreads, threadFactory, maxEventsAtOnce, DefaultSelectStrategyFactory.INSTANCE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance using the specified number of threads, the given {@link ThreadFactory} and the given
|
|
|
|
* maximal amount of epoll events to handle per epollWait(...).
|
|
|
|
*
|
|
|
|
* @deprecated Use {@link #EpollEventLoopGroup(int)}, {@link #EpollEventLoopGroup(int, ThreadFactory)}, or
|
|
|
|
* {@link #EpollEventLoopGroup(int, SelectStrategyFactory)}
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, int maxEventsAtOnce,
|
|
|
|
SelectStrategyFactory selectStrategyFactory) {
|
2019-01-23 08:32:05 +01:00
|
|
|
super(nThreads, threadFactory, EpollHandler.newFactory(maxEventsAtOnce, selectStrategyFactory));
|
2014-02-15 22:26:36 +01:00
|
|
|
}
|
|
|
|
|
2016-04-19 19:02:01 +02:00
|
|
|
public EpollEventLoopGroup(int nThreads, Executor executor, SelectStrategyFactory selectStrategyFactory) {
|
2019-01-23 08:32:05 +01:00
|
|
|
super(nThreads, executor, EpollHandler.newFactory(0, selectStrategyFactory));
|
2014-02-15 22:26:36 +01:00
|
|
|
}
|
|
|
|
}
|