public class DefaultEventLoopGroupProvider extends Object implements EventLoopGroupProvider
| Modifier and Type | Class and Description |
|---|---|
static interface |
DefaultEventLoopGroupProvider.ThreadFactoryProvider
Interface to provide a custom
ThreadFactory. |
| Modifier and Type | Field and Description |
|---|---|
protected static io.netty.util.internal.logging.InternalLogger |
logger |
| Constructor and Description |
|---|
DefaultEventLoopGroupProvider(int numberOfThreads)
Creates a new instance of
DefaultEventLoopGroupProvider. |
DefaultEventLoopGroupProvider(int numberOfThreads,
DefaultEventLoopGroupProvider.ThreadFactoryProvider threadFactoryProvider)
Creates a new instance of
DefaultEventLoopGroupProvider. |
DefaultEventLoopGroupProvider(int numberOfThreads,
ThreadFactoryProvider threadFactoryProvider)
Creates a new instance of
DefaultEventLoopGroupProvider. |
| Modifier and Type | Method and Description |
|---|---|
<T extends io.netty.channel.EventLoopGroup> |
allocate(Class<T> type)
Retrieve a
EventLoopGroup for the channel type. |
static <T extends io.netty.util.concurrent.EventExecutorGroup> |
createEventLoopGroup(Class<T> type,
int numberOfThreads)
Create an instance of a
EventExecutorGroup using the default DefaultEventLoopGroupProvider.ThreadFactoryProvider. |
protected <T extends io.netty.channel.EventLoopGroup> |
doCreateEventLoopGroup(Class<T> type,
int numberOfThreads,
ThreadFactoryProvider threadFactoryProvider)
Customization hook for
EventLoopGroup creation. |
io.netty.util.concurrent.Promise<Boolean> |
release(io.netty.util.concurrent.EventExecutorGroup eventLoopGroup,
long quietPeriod,
long timeout,
TimeUnit unit)
Release a
eventLoopGroup instance. |
io.netty.util.concurrent.Future<Boolean> |
shutdown(long quietPeriod,
long timeout,
TimeUnit timeUnit)
Shutdown the provider and release all instances.
|
int |
threadPoolSize()
Returns the pool size (number of threads) for IO threads.
|
public DefaultEventLoopGroupProvider(int numberOfThreads)
DefaultEventLoopGroupProvider.numberOfThreads - number of threads (pool size)public DefaultEventLoopGroupProvider(int numberOfThreads,
DefaultEventLoopGroupProvider.ThreadFactoryProvider threadFactoryProvider)
DefaultEventLoopGroupProvider.numberOfThreads - number of threads (pool size)threadFactoryProvider - provides access to ThreadFactory.public DefaultEventLoopGroupProvider(int numberOfThreads,
ThreadFactoryProvider threadFactoryProvider)
DefaultEventLoopGroupProvider.numberOfThreads - number of threads (pool size)threadFactoryProvider - provides access to ThreadFactoryProvider.public <T extends io.netty.channel.EventLoopGroup> T allocate(Class<T> type)
EventLoopGroupProviderEventLoopGroup for the channel type. Do not terminate or shutdown the
instance. Call the EventLoopGroupProvider.release(EventExecutorGroup, long, long, TimeUnit) to release an individual instance or
EventLoopGroupProvider.shutdown(long, long, TimeUnit) method to free the all resources.allocate in interface EventLoopGroupProviderT - type of the EventLoopGrouptype - class of the EventLoopGroup, must not be nullEventLoopGroup.protected <T extends io.netty.channel.EventLoopGroup> io.netty.util.concurrent.EventExecutorGroup doCreateEventLoopGroup(Class<T> type, int numberOfThreads, ThreadFactoryProvider threadFactoryProvider)
EventLoopGroup creation.T - type - requested event loop group type.numberOfThreads - number of threads to create.threadFactoryProvider - provider for ThreadFactory.public static <T extends io.netty.util.concurrent.EventExecutorGroup> io.netty.util.concurrent.EventExecutorGroup createEventLoopGroup(Class<T> type, int numberOfThreads)
EventExecutorGroup using the default DefaultEventLoopGroupProvider.ThreadFactoryProvider. Supported types are:
T - type parametertype - the typenumberOfThreads - the number of threads to use for the EventExecutorGroupEventExecutorGroupIllegalArgumentException - if the type is not supported.public io.netty.util.concurrent.Promise<Boolean> release(io.netty.util.concurrent.EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit)
EventLoopGroupProvidereventLoopGroup instance. The method will shutdown/terminate the EventExecutorGroup if it is no
longer needed.release in interface EventLoopGroupProvidereventLoopGroup - the eventLoopGroup instance, must not be nullquietPeriod - the quiet periodtimeout - the timeoutunit - time unit for the quiet period/the timeoutpublic int threadPoolSize()
EventLoopGroupProviderthreadPoolSize in interface EventLoopGroupProviderpublic io.netty.util.concurrent.Future<Boolean> shutdown(long quietPeriod, long timeout, TimeUnit timeUnit)
EventLoopGroupProvidershutdown in interface EventLoopGroupProviderquietPeriod - the quiet periodtimeout - the timeouttimeUnit - the unit of quietPeriod and timeoutCopyright © 2024 lettuce.io. All rights reserved.