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. |
| Modifier and Type | Method and Description |
|---|---|
<T extends EventLoopGroup> |
allocate(Class<T> type)
|
static <T extends EventExecutorGroup> |
createEventLoopGroup(Class<T> type,
int numberOfThreads)
Create an instance of a
EventExecutorGroup using the default DefaultEventLoopGroupProvider.ThreadFactoryProvider. |
protected <T extends EventLoopGroup> |
doCreateEventLoopGroup(Class<T> type,
int numberOfThreads,
DefaultEventLoopGroupProvider.ThreadFactoryProvider threadFactoryProvider)
Customization hook for
EventLoopGroup creation. |
Promise<Boolean> |
release(EventExecutorGroup eventLoopGroup,
long quietPeriod,
long timeout,
TimeUnit unit)
Release a
eventLoopGroup instance. |
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.
|
protected static final io.netty.util.internal.logging.InternalLogger logger
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 <T extends 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 EventLoopGroup.type - class of the EventLoopGroup, must not be null.EventLoopGroup.protected <T extends EventLoopGroup> EventExecutorGroup doCreateEventLoopGroup(Class<T> type, int numberOfThreads, DefaultEventLoopGroupProvider.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 EventExecutorGroup> EventExecutorGroup createEventLoopGroup(Class<T> type, int numberOfThreads)
EventExecutorGroup using the default DefaultEventLoopGroupProvider.ThreadFactoryProvider. Supported types are:
T - type parameter.type - the type.numberOfThreads - the number of threads to use for the EventExecutorGroup.EventExecutorGroup.IllegalArgumentException - if the type is not supported.public Promise<Boolean> release(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 null.quietPeriod - the quiet period.timeout - the timeout.unit - time unit for the quiet period/the timeout.public int threadPoolSize()
EventLoopGroupProviderthreadPoolSize in interface EventLoopGroupProviderpublic Future<Boolean> shutdown(long quietPeriod, long timeout, TimeUnit timeUnit)
EventLoopGroupProvidershutdown in interface EventLoopGroupProviderquietPeriod - the quiet period.timeout - the timeout.timeUnit - the unit of quietPeriod and timeout.Copyright © 2020 lettuce.io. All rights reserved.