Top Description Fields Methods
reactor.netty5.resources

public Interface LoopResources

extends Disposable
Known Direct Implementers
reactor.netty5.tcp.TcpResources, reactor.netty5.udp.UdpResources, reactor.netty5.resources.DefaultLoopResources
Annotations
@FunctionalInterface
Imports
java.net.ProtocolFamily, java.time.Duration, java.util.Objects, io.netty5.channel.Channel, .EventLoop, .EventLoopGroup, .ServerChannel, reactor.core.Disposable, reactor.core.publisher.Mono, reactor.netty5.ReactorNetty, reactor.util.annotation.Nullable

An EventLoopGroup selector with associated io.netty5.channel.Channel factories.
Author
Stephane Maldini
Since
0.6

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_IO_SELECT_COUNT

Default selector thread count, fallback to -1 (no selector thread)

public static final int
DEFAULT_IO_WORKER_COUNT

Default worker thread count, fallback to available processor (but with a minimum value of 4)

public static final boolean
DEFAULT_NATIVE

Default value whether the native transport (epoll, kqueue) will be preferred, fallback it will be preferred when available

public static final long
DEFAULT_SHUTDOWN_QUIET_PERIOD

Default quiet period that guarantees that the disposal of the underlying LoopResources will not happen, fallback to 2 seconds.

public static final 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.

Method Summary

Modifier and TypeMethod and Description
public static EventLoopGroup

Returns:

a decorated EventLoopGroup that will colocate executions on the same thread stack
colocate
(EventLoopGroup
the EventLoopGroup to decorate
group
)

Create a delegating EventLoopGroup which reuse local event loop if already working inside one.

public static LoopResources

Returns:

a new LoopResources to provide automatically for EventLoopGroup and Channel factories
create
(String
the event loop thread name prefix
prefix
)

Create a simple LoopResources to provide automatically for EventLoopGroup and Channel factories

public static LoopResources

Returns:

a new LoopResources to provide automatically for EventLoopGroup and Channel factories
create
(String
the event loop thread name prefix
prefix
,
int
number of worker threads
workerCount
,
boolean
should the thread be released on jvm shutdown
daemon
)

Create a simple LoopResources to provide automatically for EventLoopGroup and Channel factories

public static LoopResources

Returns:

a new LoopResources to provide automatically for EventLoopGroup and Channel factories
create
(String
the event loop thread name prefix
prefix
,
int
number of selector threads
selectCount
,
int
number of worker threads
workerCount
,
boolean
should the thread be released on jvm shutdown
daemon
)

Create a simple LoopResources to provide automatically for EventLoopGroup and Channel factories

public default boolean

Returns:

true if EventLoopGroup should not be shutdown
daemon
()

return true if EventLoopGroup should not be shutdown

public default void
dispose()

Implements reactor.core.Disposable.dispose.

Dispose the underlying LoopResources.
public default Mono<Void>

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.

public default Mono<Void>

Returns:

a Mono representing the completion of the LoopResources disposal.
disposeLater
(Duration
the quiet period as described above
quietPeriod
,
Duration
the maximum amount of time to wait until the disposal of the underlying LoopResources regardless if a task was submitted during the quiet period
timeout
)

Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to.

public static boolean

Returns:

true if environment supports native connections
hasNativeSupport
()

Return true if environment supports native connections

public default <
the Channel implementation
CHANNEL extends Channel
>
CHANNEL

Returns:

a Channel instance
onChannel
(Class<CHANNEL>
the channel type
channelType
,
EventLoop
the EventLoop to assign
eventLoop
,
ProtocolFamily
the configured ProtocolFamily to run with
protocolFamily
)

Callback for a Channel selection.

public default EventLoopGroup

Returns:

a new EventLoopGroup
onClient
(boolean
should use native group if current environment supports it
useNative
)

Callback for client EventLoopGroup creation.

public EventLoopGroup

Returns:

a new EventLoopGroup
onServer
(boolean
should use native group if current environment supports it
useNative
)

Callback for server EventLoopGroup creation, this is the EventLoopGroup for the child channel.

public default <
the ServerChannel implementation
SERVERCHANNEL extends ServerChannel
>
SERVERCHANNEL

Returns:

a ServerChannel instance
onServerChannel
(Class<SERVERCHANNEL>
the channel type
channelType
,
EventLoop
the EventLoop to assign
eventLoop
,
EventLoopGroup
the EventLoop to assign for child Channel
childEventLoopGroup
,
ProtocolFamily
the configured ProtocolFamily to run with
protocolFamily
)

Callback for a Channel selection.

public default EventLoopGroup

Returns:

a new EventLoopGroup
onServerSelect
(boolean
should use native group if current environment supports it
useNative
)

Callback for server select EventLoopGroup creation, this is the EventLoopGroup for the acceptor channel.

Inherited from reactor.core.Disposable:
isDisposed

Field Detail

DEFAULT_IO_SELECT_COUNTback to summary
public static final int DEFAULT_IO_SELECT_COUNT

Default selector thread count, fallback to -1 (no selector thread)

DEFAULT_IO_WORKER_COUNTback to summary
public static final int DEFAULT_IO_WORKER_COUNT

Default worker thread count, fallback to available processor (but with a minimum value of 4)

DEFAULT_NATIVEback to summary
public static final boolean DEFAULT_NATIVE

Default value whether the native transport (epoll, kqueue) will be preferred, fallback it will be preferred when available

DEFAULT_SHUTDOWN_QUIET_PERIODback to summary
public static final long DEFAULT_SHUTDOWN_QUIET_PERIOD

Default quiet period that guarantees that the disposal of the underlying LoopResources will not happen, fallback to 2 seconds.

DEFAULT_SHUTDOWN_TIMEOUTback to summary
public static final 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.

Method Detail

colocateback to summary
public static EventLoopGroup colocate(EventLoopGroup group)

Create a delegating EventLoopGroup which reuse local event loop if already working inside one.

Parameters
group:EventLoopGroup

the EventLoopGroup to decorate

Returns:EventLoopGroup

a decorated EventLoopGroup that will colocate executions on the same thread stack

createback to summary
public static LoopResources create(String prefix)

Create a simple LoopResources to provide automatically for EventLoopGroup and Channel factories

Parameters
prefix:String

the event loop thread name prefix

Returns:LoopResources

a new LoopResources to provide automatically for EventLoopGroup and Channel factories

createback to summary
public static LoopResources create(String prefix, int workerCount, boolean daemon)

Create a simple LoopResources to provide automatically for EventLoopGroup and Channel factories

Parameters
prefix:String

the event loop thread name prefix

workerCount:int

number of worker threads

daemon:boolean

should the thread be released on jvm shutdown

Returns:LoopResources

a new LoopResources to provide automatically for EventLoopGroup and Channel factories

createback to summary
public static LoopResources create(String prefix, int selectCount, int workerCount, boolean daemon)

Create a simple LoopResources to provide automatically for EventLoopGroup and Channel factories

Parameters
prefix:String

the event loop thread name prefix

selectCount:int

number of selector threads

workerCount:int

number of worker threads

daemon:boolean

should the thread be released on jvm shutdown

Returns:LoopResources

a new LoopResources to provide automatically for EventLoopGroup and Channel factories

daemonback to summary
public default boolean daemon()

return true if EventLoopGroup should not be shutdown

Returns:boolean

true if EventLoopGroup should not be shutdown

disposeback to summary
public default void dispose()

Implements reactor.core.Disposable.dispose.

Dispose the underlying LoopResources. This method is NOT blocking. It is implemented as fire-and-forget. Use 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.

Annotations
@Override
@SuppressWarnings:FunctionalInterfaceMethodChanged
disposeLaterback to summary
public default Mono<Void> disposeLater()

Returns a Mono that triggers the disposal of the underlying LoopResources when subscribed to. The quiet period will be 2s and the timeout will be 15s

Returns:Mono<Void>

a Mono representing the completion of the LoopResources disposal.

disposeLaterback to summary
public default Mono<Void> disposeLater(Duration quietPeriod, Duration timeout)

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 before quietPeriod is over. If a task is submitted during the quietPeriod, it is guaranteed to be accepted and the quietPeriod will start over.

Parameters
quietPeriod:Duration

the quiet period as described above

timeout:Duration

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:Mono<Void>

a Mono representing the completion of the LoopResources disposal.

Since
0.9.3
hasNativeSupportback to summary
public static boolean hasNativeSupport()

Return true if environment supports native connections

Returns:boolean

true if environment supports native connections

onChannelback to summary
public default <CHANNEL extends Channel> CHANNEL onChannel(Class<CHANNEL> channelType, EventLoop eventLoop, ProtocolFamily protocolFamily)

Callback for a Channel selection.

Parameters
<CHANNEL>
the Channel implementation
channelType:Class<CHANNEL>

the channel type

eventLoop:EventLoop

the EventLoop to assign

protocolFamily:ProtocolFamily

the configured ProtocolFamily to run with

Returns:CHANNEL

a Channel instance

onClientback to summary
public default EventLoopGroup onClient(boolean useNative)

Callback for client EventLoopGroup creation.

Parameters
useNative:boolean

should use native group if current environment supports it

Returns:EventLoopGroup

a new EventLoopGroup

onServerback to summary
public EventLoopGroup onServer(boolean useNative)

Callback for server EventLoopGroup creation, this is the EventLoopGroup for the child channel.

Parameters
useNative:boolean

should use native group if current environment supports it

Returns:EventLoopGroup

a new EventLoopGroup

onServerChannelback to summary
public default <SERVERCHANNEL extends ServerChannel> SERVERCHANNEL onServerChannel(Class<SERVERCHANNEL> channelType, EventLoop eventLoop, EventLoopGroup childEventLoopGroup, ProtocolFamily protocolFamily)

Callback for a Channel selection.

Parameters
<SERVERCHANNEL>
the ServerChannel implementation
channelType:Class<SERVERCHANNEL>

the channel type

eventLoop:EventLoop

the EventLoop to assign

childEventLoopGroup:EventLoopGroup

the EventLoop to assign for child Channel

protocolFamily:ProtocolFamily

the configured ProtocolFamily to run with

Returns:SERVERCHANNEL

a ServerChannel instance

onServerSelectback to summary
public default EventLoopGroup onServerSelect(boolean useNative)

Callback for server select EventLoopGroup creation, this is the EventLoopGroup for the acceptor channel.

Parameters
useNative:boolean

should use native group if current environment supports it

Returns:EventLoopGroup

a new EventLoopGroup