public final class ChannelSet extends java.lang.Object implements ListenableAsyncCloseable
Channels to provide a mechanism for closing all of them.
Channels are removed from the set when they are closed.
| Modifier and Type | Field and Description |
|---|---|
static io.netty.util.AttributeKey<AsyncCloseable> |
CHANNEL_CLOSEABLE_KEY |
| Constructor and Description |
|---|
ChannelSet(Executor offloadingExecutor)
New instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addIfAbsent(io.netty.channel.Channel channel)
Add a
Channel to this ChannelSet, if it is not already present. |
Completable |
closeAsync()
Used to close/shutdown a resource.
|
Completable |
closeAsyncGracefully()
Used to close/shutdown a resource, similar to
AsyncCloseable.closeAsync(), but attempts to cleanup state before
abruptly closing. |
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
public static final io.netty.util.AttributeKey<AsyncCloseable> CHANNEL_CLOSEABLE_KEY
public boolean addIfAbsent(io.netty.channel.Channel channel)
Channel to this ChannelSet, if it is not already present. Channel.id() is used to
check uniqueness.channel - The Channel to add.true if the channel was added successfully, false otherwise.public Completable closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseableCompletableSource that is notified once the close is complete.public Completable closeAsyncGracefully()
AsyncCloseableAsyncCloseable.closeAsync(), but attempts to cleanup state before
abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in
flight work. This method is implemented on a "best effort" basis and may be equivalent to AsyncCloseable.closeAsync().
Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not
want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a
timeout and force a call to AsyncCloseable.closeAsync().
closeAsyncGracefully in interface AsyncCloseableCompletable that is notified once the close is complete.public Completable onClose()
ListenableAsyncCloseableCompletable that is notified once the ListenableAsyncCloseable was closed.onClose in interface ListenableAsyncCloseableCompletable that is notified on close.