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 intDefault selector thread count, fallback to -1 (no selector thread).static final intDefault worker thread count, fallback to available processor (but with a minimum value of 4).static final booleanDefault value whether the native transport (epoll, io_uring, kqueue) will be preferred, fallback it will be preferred when available.static final longDefault quiet period that guarantees that the disposal of the underlying LoopResources will not happen, fallback to 2 seconds.static final longDefault 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 EventLoopGroupcolocate(EventLoopGroup group) Create a delegatingEventLoopGroupwhich reuse local event loop if already working inside one.static LoopResourcesstatic LoopResourcesstatic LoopResourcesstatic LoopResourcesdefault booleandaemon()return true ifEventLoopGroupshould not be shutdown.default voiddispose()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 booleanReturn true if environment supports native connections.default <CHANNEL extends Channel>
CHANNELonChannel(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannelselection.onChannelClass(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannelclass selection.default EventLoopGrouponClient(boolean useNative) Callback for clientEventLoopGroupcreation.onServer(boolean useNative) Callback for serverEventLoopGroupcreation, this is theEventLoopGroupfor the child channel.default EventLoopGrouponServerSelect(boolean useNative) Callback for server selectEventLoopGroupcreation, this is theEventLoopGroupfor 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, io_uring, 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 delegatingEventLoopGroupwhich reuse local event loop if already working inside one.- Parameters:
group- theEventLoopGroupto decorate- Returns:
- a decorated
EventLoopGroupthat will colocate executions on the same thread stack
-
create
- Parameters:
prefix- the event loop thread name prefix- Returns:
- a new
LoopResourcesto provide automatically forEventLoopGroupandChannelfactories
-
create
- Parameters:
prefix- the event loop thread name prefixworkerCount- number of worker threadsdaemon- should the thread be released on jvm shutdown- Returns:
- a new
LoopResourcesto provide automatically forEventLoopGroupandChannelfactories
-
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
LoopResourcesto provide automatically forEventLoopGroupandChannelfactories
-
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 thatEventLoopGroupcreated for clients will reuse current local event loop if already working inside one.- Returns:
- a new
LoopResourcesto provide automatically forEventLoopGroupandChannelfactories - Since:
- 1.0.28
-
daemon
default boolean daemon()return true ifEventLoopGroupshould not be shutdown.- Returns:
- true if
EventLoopGroupshould 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:
disposein interfaceDisposable
-
disposeLater
Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to. The quiet period will be2sand 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 beforequietPeriodis over. If a task is submitted during thequietPeriod, it is guaranteed to be accepted and thequietPeriodwill 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 aChannelselection.- Type Parameters:
CHANNEL- theChannelimplementation- Parameters:
channelType- the channel typegroup- the sourceEventLoopGroupto assign a loop from- Returns:
- a
Channelinstance
-
onChannelClass
default <CHANNEL extends Channel> Class<? extends CHANNEL> onChannelClass(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannelclass selection.- Type Parameters:
CHANNEL- theChannelimplementation- Parameters:
channelType- the channel typegroup- the sourceEventLoopGroupto assign a loop from- Returns:
- a
Channelclass
-
onClient
Callback for clientEventLoopGroupcreation.- Parameters:
useNative- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
onServer
Callback for serverEventLoopGroupcreation, this is theEventLoopGroupfor the child channel.- Parameters:
useNative- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
onServerSelect
Callback for server selectEventLoopGroupcreation, this is theEventLoopGroupfor 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
-