public class UdpResources extends Object implements LoopResources
Disposable.Composite, Disposable.Swap
DEFAULT_IO_SELECT_COUNT, DEFAULT_IO_WORKER_COUNT, DEFAULT_NATIVE
Modifier | Constructor and Description |
---|---|
protected |
UdpResources(LoopResources defaultLoops) |
Modifier and Type | Method and Description |
---|---|
protected void |
_dispose()
Dispose underlying resources
|
protected Mono<Void> |
_disposeLater()
Dispose underlying resources in a listenable fashion.
|
boolean |
daemon()
return true if
EventLoopGroup should not be shutdown |
void |
dispose() |
Mono<Void> |
disposeLater()
Returns a Mono that triggers the disposal of underlying resources when subscribed to.
|
static UdpResources |
get()
Return the global UDP resources for pooling
|
protected static UdpResources |
getOrCreate(LoopResources loops,
java.util.function.Function<LoopResources,UdpResources> onNew,
String name)
Safely check if existing resource exist and proceed to update/cleanup if new
resources references are passed.
|
boolean |
isDisposed() |
Class<? extends Channel> |
onChannel(EventLoopGroup group)
Callback for client or generic channel factory selection.
|
EventLoopGroup |
onClient(boolean useNative)
Callback for client
EventLoopGroup creation. |
Class<? extends DatagramChannel> |
onDatagramChannel(EventLoopGroup group)
Callback for UDP channel factory selection.
|
EventLoopGroup |
onServer(boolean useNative)
Callback for server
EventLoopGroup creation. |
Class<? extends ServerChannel> |
onServerChannel(EventLoopGroup group)
Callback for server channel factory selection.
|
EventLoopGroup |
onServerSelect(boolean useNative)
Create a server select
EventLoopGroup for servers to be used |
boolean |
preferNative()
Return true if should default to native
EventLoopGroup and Channel |
static UdpResources |
reset()
Reset UDP resources to default and return its instance
|
static UdpResources |
set(LoopResources loops)
Update pooling resources and return the global UDP resources
|
static void |
shutdown()
Shutdown the global
UdpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
static Mono<Void> |
shutdownLater()
Prepare to shutdown the global
UdpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
colocate, create, create, create
protected UdpResources(LoopResources defaultLoops)
public static UdpResources get()
public static UdpResources set(LoopResources loops)
loops
- the eventual new LoopResources
public static UdpResources reset()
public static void shutdown()
UdpResources
without resetting them,
effectively cleaning up associated resources without creating new ones.public static Mono<Void> shutdownLater()
UdpResources
without resetting them,
effectively cleaning up associated resources without creating new ones. This only
occurs when the returned Mono
is subscribed to.Mono
triggering the shutdown()
when subscribed to.public void dispose()
dispose
in interface Disposable
dispose
in interface LoopResources
public Mono<Void> disposeLater()
LoopResources
disposeLater
in interface LoopResources
protected void _dispose()
protected Mono<Void> _disposeLater()
public boolean isDisposed()
isDisposed
in interface Disposable
public Class<? extends Channel> onChannel(EventLoopGroup group)
LoopResources
onChannel
in interface LoopResources
group
- the source EventLoopGroup
to assign a loop fromClass
target for the underlying Channel
factorypublic EventLoopGroup onClient(boolean useNative)
LoopResources
EventLoopGroup
creation.onClient
in interface LoopResources
useNative
- should use native group if current LoopResources.preferNative()
is also
trueEventLoopGroup
public Class<? extends DatagramChannel> onDatagramChannel(EventLoopGroup group)
LoopResources
onDatagramChannel
in interface LoopResources
group
- the source EventLoopGroup
to assign a loop fromClass
target for the underlying Channel
factorypublic EventLoopGroup onServer(boolean useNative)
LoopResources
EventLoopGroup
creation.onServer
in interface LoopResources
useNative
- should use native group if current LoopResources.preferNative()
is also
trueEventLoopGroup
public Class<? extends ServerChannel> onServerChannel(EventLoopGroup group)
LoopResources
onServerChannel
in interface LoopResources
group
- the source EventLoopGroup
to assign a loop fromClass
target for the underlying ServerChannel
factorypublic EventLoopGroup onServerSelect(boolean useNative)
LoopResources
EventLoopGroup
for servers to be usedonServerSelect
in interface LoopResources
useNative
- should use native group if current LoopResources.preferNative()
is also
trueEventLoopGroup
public boolean preferNative()
LoopResources
EventLoopGroup
and Channel
preferNative
in interface LoopResources
EventLoopGroup
and Channel
public boolean daemon()
LoopResources
EventLoopGroup
should not be shutdowndaemon
in interface LoopResources
EventLoopGroup
should not be shutdownprotected static UdpResources getOrCreate(@Nullable LoopResources loops, java.util.function.Function<LoopResources,UdpResources> onNew, String name)
loops
- the eventual new LoopResources
onNew
- a UdpResources
factoryname
- a name for resourcesUdpResources