@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 quite 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(java.time.Duration quietPeriod,
java.time.Duration timeout)
Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to.
|
static boolean |
hasNativeSupport()
Returns true if native transport is available.
|
default <CHANNEL extends Channel> |
onChannel(Class<CHANNEL> channelType,
EventLoopGroup group)
Callback for a
Channel selection. |
default Class<? extends Channel> |
onChannel(EventLoopGroup group)
Deprecated.
as of 0.9.8. See
onChannel(Class, EventLoopGroup) |
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. |
default Class<? extends DatagramChannel> |
onDatagramChannel(EventLoopGroup group)
Deprecated.
as of 0.9.8. See
onChannel(Class, EventLoopGroup) |
EventLoopGroup |
onServer(boolean useNative)
Callback for server
EventLoopGroup creation,
this is the EventLoopGroup for the child channel. |
default Class<? extends ServerChannel> |
onServerChannel(EventLoopGroup group)
Deprecated.
as of 0.9.8. See
onChannel(Class, EventLoopGroup) |
default EventLoopGroup |
onServerSelect(boolean useNative)
Callback for server select
EventLoopGroup creation,
this is the EventLoopGroup for the acceptor channel. |
default boolean |
preferNative()
Deprecated.
as of 0.9.8. Use
hasNativeSupport() |
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, 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
factoriesstatic LoopResources create(String prefix)
prefix
- the event loop thread name prefixLoopResources
to provide automatically for EventLoopGroup
and Channel
factories@Deprecated default Class<? extends Channel> onChannel(EventLoopGroup group)
onChannel(Class, EventLoopGroup)
group
- the source EventLoopGroup
to assign a loop fromClass
target for the underlying Channel
factorydefault <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
@Deprecated default Class<? extends DatagramChannel> onDatagramChannel(EventLoopGroup group)
onChannel(Class, EventLoopGroup)
group
- the source EventLoopGroup
to assign a loop fromClass
target for the underlying Channel
factoryEventLoopGroup onServer(boolean useNative)
EventLoopGroup
creation,
this is the EventLoopGroup
for the child channel.useNative
- should use native group if current environment supports itEventLoopGroup
@Deprecated default Class<? extends ServerChannel> onServerChannel(EventLoopGroup group)
onChannel(Class, EventLoopGroup)
group
- the source EventLoopGroup
to assign a loop fromClass
target for the underlying ServerChannel
factorydefault EventLoopGroup onServerSelect(boolean useNative)
EventLoopGroup
creation,
this is the EventLoopGroup
for the acceptor channel.useNative
- should use native group if current environment supports itEventLoopGroup
@Deprecated default boolean preferNative()
hasNativeSupport()
EventLoopGroup
and Channel
EventLoopGroup
and Channel
default 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(java.time.Duration quietPeriod, java.time.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 periodstatic boolean hasNativeSupport()