Package reactor.netty.resources
Interface LoopResources
- All Superinterfaces:
Disposable
- All Known Implementing Classes:
HttpResources
,QuicResources
,TcpResources
,UdpResources
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
An
EventLoopGroup
selector with associated
Channel
factories.- Since:
- 0.6
- Author:
- Stephane Maldini
-
Nested Class Summary
Nested classes/interfaces inherited from interface reactor.core.Disposable
Disposable.Composite, Disposable.Swap
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Default selector thread count, fallback to -1 (no selector thread).static final int
Default worker thread count, fallback to available processor (but with a minimum value of 4).static final boolean
Default value whether the native transport (epoll, kqueue) will be preferred, fallback it will be preferred when available.static final long
Default quiet period that guarantees that the disposal of the underlying LoopResources will not happen, fallback to 2 seconds.static final long
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. -
Method Summary
Modifier and TypeMethodDescriptionstatic EventLoopGroup
colocate
(EventLoopGroup group) Create a delegatingEventLoopGroup
which reuse local event loop if already working inside one.static LoopResources
static LoopResources
static LoopResources
static LoopResources
default boolean
daemon()
return true ifEventLoopGroup
should not be shutdown.default void
dispose()
Dispose the underlying LoopResources.Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to.disposeLater
(Duration quietPeriod, Duration timeout) Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to.static boolean
Return true if environment supports native connections.default <CHANNEL extends Channel>
CHANNELonChannel
(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannel
selection.onChannelClass
(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannel
class selection.default EventLoopGroup
onClient
(boolean useNative) Callback for clientEventLoopGroup
creation.onServer
(boolean useNative) Callback for serverEventLoopGroup
creation, this is theEventLoopGroup
for the child channel.default EventLoopGroup
onServerSelect
(boolean useNative) Callback for server selectEventLoopGroup
creation, this is theEventLoopGroup
for the acceptor channel.Methods inherited from interface reactor.core.Disposable
isDisposed
-
Field Details
-
DEFAULT_IO_WORKER_COUNT
static final int DEFAULT_IO_WORKER_COUNTDefault worker thread count, fallback to available processor (but with a minimum value of 4). -
DEFAULT_IO_SELECT_COUNT
static final int DEFAULT_IO_SELECT_COUNTDefault selector thread count, fallback to -1 (no selector thread). -
DEFAULT_NATIVE
static final boolean DEFAULT_NATIVEDefault value whether the native transport (epoll, kqueue) will be preferred, fallback it will be preferred when available. -
DEFAULT_SHUTDOWN_QUIET_PERIOD
static final long DEFAULT_SHUTDOWN_QUIET_PERIODDefault quiet period that guarantees that the disposal of the underlying LoopResources will not happen, fallback to 2 seconds. -
DEFAULT_SHUTDOWN_TIMEOUT
static final long DEFAULT_SHUTDOWN_TIMEOUTDefault 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.
-
-
Method Details
-
colocate
Create a delegatingEventLoopGroup
which reuse local event loop if already working inside one.- Parameters:
group
- theEventLoopGroup
to decorate- Returns:
- a decorated
EventLoopGroup
that will colocate executions on the same thread stack
-
create
- Parameters:
prefix
- the event loop thread name prefix- Returns:
- a new
LoopResources
to provide automatically forEventLoopGroup
andChannel
factories
-
create
- Parameters:
prefix
- the event loop thread name prefixworkerCount
- number of worker threadsdaemon
- should the thread be released on jvm shutdown- Returns:
- a new
LoopResources
to provide automatically forEventLoopGroup
andChannel
factories
-
create
- Parameters:
prefix
- the event loop thread name prefixselectCount
- number of selector threadsworkerCount
- number of worker threadsdaemon
- should the thread be released on jvm shutdown- Returns:
- a new
LoopResources
to provide automatically forEventLoopGroup
andChannel
factories
-
create
static LoopResources create(String prefix, int selectCount, int workerCount, boolean daemon, boolean colocate) - Parameters:
prefix
- the event loop thread name prefixselectCount
- number of selector threads. When -1 is specified, no selectors threads will be created, and worker threads will be also used as selector threads.workerCount
- number of worker threadsdaemon
- should the thread be released on jvm shutdowncolocate
- true means thatEventLoopGroup
created for clients will reuse current local event loop if already working inside one.- Returns:
- a new
LoopResources
to provide automatically forEventLoopGroup
andChannel
factories - Since:
- 1.0.28
-
daemon
default boolean daemon()return true ifEventLoopGroup
should not be shutdown.- Returns:
- true if
EventLoopGroup
should not be shutdown
-
dispose
default void dispose()Dispose the underlying LoopResources. This method is NOT blocking. It is implemented as fire-and-forget. UsedisposeLater()
when you need to observe the final status of the operation, combined withMono.block()
if you need to synchronously wait for the underlying resources to be disposed.- Specified by:
dispose
in interfaceDisposable
-
disposeLater
Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to. The quiet period will be2s
and the timeout will be15s
- Returns:
- a Mono representing the completion of the LoopResources disposal.
-
disposeLater
Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to. It is guaranteed that the disposal of the underlying LoopResources will not happen beforequietPeriod
is over. If a task is submitted during thequietPeriod
, it is guaranteed to be accepted and thequietPeriod
will start over.- Parameters:
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 period- Returns:
- a Mono representing the completion of the LoopResources disposal.
- Since:
- 0.9.3
-
onChannel
default <CHANNEL extends Channel> CHANNEL onChannel(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannel
selection.- Type Parameters:
CHANNEL
- theChannel
implementation- Parameters:
channelType
- the channel typegroup
- the sourceEventLoopGroup
to assign a loop from- Returns:
- a
Channel
instance
-
onChannelClass
default <CHANNEL extends Channel> Class<? extends CHANNEL> onChannelClass(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannel
class selection.- Type Parameters:
CHANNEL
- theChannel
implementation- Parameters:
channelType
- the channel typegroup
- the sourceEventLoopGroup
to assign a loop from- Returns:
- a
Channel
class
-
onClient
Callback for clientEventLoopGroup
creation.- Parameters:
useNative
- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
onServer
Callback for serverEventLoopGroup
creation, this is theEventLoopGroup
for the child channel.- Parameters:
useNative
- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
onServerSelect
Callback for server selectEventLoopGroup
creation, this is theEventLoopGroup
for the acceptor channel.- Parameters:
useNative
- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
hasNativeSupport
static boolean hasNativeSupport()Return true if environment supports native connections.- Returns:
- true if environment supports native connections
-