@FunctionalInterface public interface LoopResources extends Disposable
EventLoopGroup
selector with associated
Channel
factories.Disposable.Composite, Disposable.Swap
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_IO_SELECT_COUNT
Default selector thread count, fallback to -1 (no selector thread)
|
static int |
DEFAULT_IO_WORKER_COUNT
Default worker thread count, fallback to available processor
(but with a minimum value of 4)
|
static boolean |
DEFAULT_NATIVE
Default value whether the native transport (epoll, kqueue) will be preferred,
fallback it will be preferred when available
|
static long |
DEFAULT_SHUTDOWN_QUIET_PERIOD
Default quiet period that guarantees that the disposal of the underlying LoopResources
will not happen, fallback to 2 seconds.
|
static long |
DEFAULT_SHUTDOWN_TIMEOUT
Default maximum amount of time to wait until the disposal of the underlying LoopResources
regardless if a task was submitted during the quiet period, fallback to 15 seconds.
|
Modifier and Type | Method and Description |
---|---|
static EventLoopGroup |
colocate(EventLoopGroup group)
Create a delegating
EventLoopGroup which reuse local event loop if already
working
inside one. |
static LoopResources |
create(String prefix)
|
static LoopResources |
create(String prefix,
int workerCount,
boolean daemon)
|
static LoopResources |
create(String prefix,
int selectCount,
int workerCount,
boolean daemon)
|
default boolean |
daemon()
return true if
EventLoopGroup should not be shutdown |
default void |
dispose()
Dispose the underlying LoopResources.
|
default Mono<Void> |
disposeLater()
Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to.
|
default Mono<Void> |
disposeLater(Duration quietPeriod,
Duration timeout)
Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to.
|
static boolean |
hasNativeSupport()
Return true if environment supports native connections
|
default <CHANNEL extends Channel> |
onChannel(Class<CHANNEL> channelType,
EventLoopGroup group)
Callback for a
Channel selection. |
default <CHANNEL extends Channel> |
onChannelClass(Class<CHANNEL> channelType,
EventLoopGroup group)
Callback for a
Channel class selection. |
default EventLoopGroup |
onClient(boolean useNative)
Callback for client
EventLoopGroup creation. |
EventLoopGroup |
onServer(boolean useNative)
Callback for server
EventLoopGroup creation,
this is the EventLoopGroup for the child channel. |
default EventLoopGroup |
onServerSelect(boolean useNative)
Callback for server select
EventLoopGroup creation,
this is the EventLoopGroup for the acceptor channel. |
isDisposed
static final int DEFAULT_IO_WORKER_COUNT
static final int DEFAULT_IO_SELECT_COUNT
static final boolean DEFAULT_NATIVE
static final long DEFAULT_SHUTDOWN_QUIET_PERIOD
static final long DEFAULT_SHUTDOWN_TIMEOUT
static EventLoopGroup colocate(EventLoopGroup group)
EventLoopGroup
which reuse local event loop if already
working
inside one.group
- the EventLoopGroup
to decorateEventLoopGroup
that will colocate executions on the
same thread stackstatic LoopResources create(String prefix)
prefix
- the event loop thread name prefixLoopResources
to provide automatically for EventLoopGroup
and Channel
factoriesstatic LoopResources create(String prefix, int workerCount, boolean daemon)
prefix
- the event loop thread name prefixworkerCount
- number of worker threadsdaemon
- should the thread be released on jvm shutdownLoopResources
to provide automatically for EventLoopGroup
and Channel
factoriesstatic LoopResources create(String prefix, int selectCount, int workerCount, boolean daemon)
prefix
- the event loop thread name prefixselectCount
- number of selector threadsworkerCount
- number of worker threadsdaemon
- should the thread be released on jvm shutdownLoopResources
to provide automatically for EventLoopGroup
and Channel
factoriesdefault boolean daemon()
EventLoopGroup
should not be shutdownEventLoopGroup
should not be shutdowndefault void dispose()
disposeLater()
when you need to observe the final
status of the operation, combined with Mono.block()
if you need to synchronously wait for the underlying resources to be disposed.dispose
in interface Disposable
default Mono<Void> disposeLater()
2s
and the timeout will be 15s
default Mono<Void> disposeLater(Duration quietPeriod, Duration timeout)
quietPeriod
is over. If a task is submitted during the quietPeriod
,
it is guaranteed to be accepted and the quietPeriod
will start over.quietPeriod
- the quiet period as described abovetimeout
- the maximum amount of time to wait until the disposal of the underlying
LoopResources regardless if a task was submitted during the quiet perioddefault <CHANNEL extends Channel> CHANNEL onChannel(Class<CHANNEL> channelType, EventLoopGroup group)
Channel
selection.CHANNEL
- the Channel
implementationchannelType
- the channel typegroup
- the source EventLoopGroup
to assign a loop fromChannel
instancedefault <CHANNEL extends Channel> Class<? extends CHANNEL> onChannelClass(Class<CHANNEL> channelType, EventLoopGroup group)
Channel
class selection.CHANNEL
- the Channel
implementationchannelType
- the channel typegroup
- the source EventLoopGroup
to assign a loop fromChannel
classdefault EventLoopGroup onClient(boolean useNative)
EventLoopGroup
creation.useNative
- should use native group if current environment supports itEventLoopGroup
EventLoopGroup onServer(boolean useNative)
EventLoopGroup
creation,
this is the EventLoopGroup
for the child channel.useNative
- should use native group if current environment supports itEventLoopGroup
default EventLoopGroup onServerSelect(boolean useNative)
EventLoopGroup
creation,
this is the EventLoopGroup
for the acceptor channel.useNative
- should use native group if current environment supports itEventLoopGroup
static boolean hasNativeSupport()