Top Description Fields Methods
reactor.netty.resources

public Interface LoopResources

extends Disposable
Known Direct Implementers
reactor.netty.tcp.TcpResources, reactor.netty.udp.UdpResources, reactor.netty.resources.DefaultLoopResources
Annotations
@FunctionalInterface
Imports
java.time.Duration, java.util.Objects, io.netty.channel.Channel, .EventLoopGroup, reactor.core.Disposable, reactor.core.publisher.Mono, reactor.netty.ReactorNetty

An EventLoopGroup selector with associated io.netty.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 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. When -1 is specified, no selectors threads will be created, and worker threads will be also used as selector threads.
selectCount
,
int
number of worker threads
workerCount
,
boolean
should the thread be released on jvm shutdown
daemon
,
boolean
true means that EventLoopGroup created for clients will reuse current local event loop if already working inside one.
colocate
)

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
,
EventLoopGroup
the source EventLoopGroup to assign a loop from
group
)

Callback for a Channel selection.

public default <
the Channel implementation
CHANNEL extends Channel
>
Class<? extends CHANNEL>

Returns:

a Channel class
onChannelClass
(Class<CHANNEL>
the channel type
channelType
,
EventLoopGroup
the source EventLoopGroup to assign a loop from
group
)

Callback for a Channel class 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 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

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

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. When -1 is specified, no selectors threads will be created, and worker threads will be also used as selector threads.

workerCount:int

number of worker threads

daemon:boolean

should the thread be released on jvm shutdown

colocate:boolean

true means that EventLoopGroup created for clients will reuse current local event loop if already working inside one.

Returns:LoopResources

a new LoopResources to provide automatically for EventLoopGroup and Channel factories

Since
1.0.28
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, EventLoopGroup group)

Callback for a Channel selection.

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

the channel type

group:EventLoopGroup

the source EventLoopGroup to assign a loop from

Returns:CHANNEL

a Channel instance

onChannelClassback to summary
public default <CHANNEL extends Channel> Class<? extends CHANNEL> onChannelClass(Class<CHANNEL> channelType, EventLoopGroup group)

Callback for a Channel class selection.

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

the channel type

group:EventLoopGroup

the source EventLoopGroup to assign a loop from

Returns:Class<? extends CHANNEL>

a Channel class

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

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