Package io.netty.channel.group
Class DefaultChannelGroupFuture
- All Implemented Interfaces:
ChannelGroupFuture
,Future<Void>
,Promise<Void>
,Iterable<ChannelFuture>
,Future<Void>
The default
ChannelGroupFuture
implementation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelFutureListener
private int
private final Map
<Channel, ChannelFuture> private final ChannelGroup
private int
Fields inherited from class io.netty.util.concurrent.DefaultPromise
PROPERTY_MAX_LISTENER_STACK_DEPTH
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultChannelGroupFuture
(ChannelGroup group, Collection<ChannelFuture> futures, EventExecutor executor) Creates a new instance.DefaultChannelGroupFuture
(ChannelGroup group, Map<Channel, ChannelFuture> futures, EventExecutor executor) -
Method Summary
Modifier and TypeMethodDescriptionaddListener
(GenericFutureListener<? extends Future<? super Void>> listener) Adds the specified listener to this future.addListeners
(GenericFutureListener<? extends Future<? super Void>>... listeners) Adds the specified listeners to this future.await()
Waits for this future to be completed.Waits for this future to be completed without interruption.cause()
Returns the cause of the failed I/O operation if the I/O operation has failed.protected void
Returns theChannelFuture
of the individual I/O operation which is associated with the specifiedChannel
.group()
Returns theChannelGroup
which is associated with this future.boolean
Returnstrue
if and only if the I/O operations associated with this future have failed partially with some success.boolean
Returnstrue
if and only if the I/O operations associated with this future were partially successful with some failure.iterator()
Returns theIterator
that enumerates allChannelFuture
s which are associated with this future.removeListener
(GenericFutureListener<? extends Future<? super Void>> listener) Removes the first occurrence of the specified listener from this future.removeListeners
(GenericFutureListener<? extends Future<? super Void>>... listeners) Removes the first occurrence for each of the listeners from this future.setFailure
(Throwable cause) Marks this future as a failure and notifies all listeners.private void
setFailure0
(ChannelGroupException cause) setSuccess
(Void result) Marks this future as a success and notifies all listeners.private void
sync()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.Waits for this future until it is done, and rethrows the cause of the failure if this future failed.boolean
tryFailure
(Throwable cause) Marks this future as a failure and notifies all listeners.boolean
trySuccess
(Void result) Marks this future as a success and notifies all listeners.Methods inherited from class io.netty.util.concurrent.DefaultPromise
await, await, awaitUninterruptibly, awaitUninterruptibly, cancel, executor, get, get, getNow, isCancellable, isCancelled, isDone, isSuccess, notifyListener, setUncancellable, toString, toStringBuilder
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.netty.channel.group.ChannelGroupFuture
isSuccess
Methods inherited from interface io.netty.util.concurrent.Future
await, await, awaitUninterruptibly, awaitUninterruptibly, cancel, getNow, isCancellable
Methods inherited from interface java.util.concurrent.Future
exceptionNow, get, get, isCancelled, isDone, resultNow, state
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
group
-
futures
-
successCount
private int successCount -
failureCount
private int failureCount -
childListener
-
-
Constructor Details
-
DefaultChannelGroupFuture
DefaultChannelGroupFuture(ChannelGroup group, Collection<ChannelFuture> futures, EventExecutor executor) Creates a new instance. -
DefaultChannelGroupFuture
DefaultChannelGroupFuture(ChannelGroup group, Map<Channel, ChannelFuture> futures, EventExecutor executor)
-
-
Method Details
-
group
Description copied from interface:ChannelGroupFuture
Returns theChannelGroup
which is associated with this future.- Specified by:
group
in interfaceChannelGroupFuture
-
find
Description copied from interface:ChannelGroupFuture
Returns theChannelFuture
of the individual I/O operation which is associated with the specifiedChannel
.- Specified by:
find
in interfaceChannelGroupFuture
- Returns:
- the matching
ChannelFuture
if found.null
otherwise.
-
iterator
Description copied from interface:ChannelGroupFuture
Returns theIterator
that enumerates allChannelFuture
s which are associated with this future. Please note that the returnedIterator
is unmodifiable, which means aChannelFuture
cannot be removed from this future.- Specified by:
iterator
in interfaceChannelGroupFuture
- Specified by:
iterator
in interfaceIterable<ChannelFuture>
-
isPartialSuccess
public boolean isPartialSuccess()Description copied from interface:ChannelGroupFuture
Returnstrue
if and only if the I/O operations associated with this future were partially successful with some failure.- Specified by:
isPartialSuccess
in interfaceChannelGroupFuture
-
isPartialFailure
public boolean isPartialFailure()Description copied from interface:ChannelGroupFuture
Returnstrue
if and only if the I/O operations associated with this future have failed partially with some success.- Specified by:
isPartialFailure
in interfaceChannelGroupFuture
-
addListener
public DefaultChannelGroupFuture addListener(GenericFutureListener<? extends Future<? super Void>> listener) Description copied from interface:Future
Adds the specified listener to this future. The specified listener is notified when this future is done. If this future is already completed, the specified listener is notified immediately.- Specified by:
addListener
in interfaceChannelGroupFuture
- Specified by:
addListener
in interfaceFuture<Void>
- Specified by:
addListener
in interfacePromise<Void>
- Overrides:
addListener
in classDefaultPromise<Void>
-
addListeners
public DefaultChannelGroupFuture addListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) Description copied from interface:Future
Adds the specified listeners to this future. The specified listeners are notified when this future is done. If this future is already completed, the specified listeners are notified immediately.- Specified by:
addListeners
in interfaceChannelGroupFuture
- Specified by:
addListeners
in interfaceFuture<Void>
- Specified by:
addListeners
in interfacePromise<Void>
- Overrides:
addListeners
in classDefaultPromise<Void>
-
removeListener
public DefaultChannelGroupFuture removeListener(GenericFutureListener<? extends Future<? super Void>> listener) Description copied from interface:Future
Removes the first occurrence of the specified listener from this future. The specified listener is no longer notified when this future is done. If the specified listener is not associated with this future, this method does nothing and returns silently.- Specified by:
removeListener
in interfaceChannelGroupFuture
- Specified by:
removeListener
in interfaceFuture<Void>
- Specified by:
removeListener
in interfacePromise<Void>
- Overrides:
removeListener
in classDefaultPromise<Void>
-
removeListeners
public DefaultChannelGroupFuture removeListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) Description copied from interface:Future
Removes the first occurrence for each of the listeners from this future. The specified listeners are no longer notified when this future is done. If the specified listeners are not associated with this future, this method does nothing and returns silently.- Specified by:
removeListeners
in interfaceChannelGroupFuture
- Specified by:
removeListeners
in interfaceFuture<Void>
- Specified by:
removeListeners
in interfacePromise<Void>
- Overrides:
removeListeners
in classDefaultPromise<Void>
-
await
Description copied from interface:Future
Waits for this future to be completed.- Specified by:
await
in interfaceChannelGroupFuture
- Specified by:
await
in interfaceFuture<Void>
- Specified by:
await
in interfacePromise<Void>
- Overrides:
await
in classDefaultPromise<Void>
- Throws:
InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
Description copied from interface:Future
Waits for this future to be completed without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceChannelGroupFuture
- Specified by:
awaitUninterruptibly
in interfaceFuture<Void>
- Specified by:
awaitUninterruptibly
in interfacePromise<Void>
- Overrides:
awaitUninterruptibly
in classDefaultPromise<Void>
-
syncUninterruptibly
Description copied from interface:Future
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
syncUninterruptibly
in interfaceChannelGroupFuture
- Specified by:
syncUninterruptibly
in interfaceFuture<Void>
- Specified by:
syncUninterruptibly
in interfacePromise<Void>
- Overrides:
syncUninterruptibly
in classDefaultPromise<Void>
-
sync
Description copied from interface:Future
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
sync
in interfaceChannelGroupFuture
- Specified by:
sync
in interfaceFuture<Void>
- Specified by:
sync
in interfacePromise<Void>
- Overrides:
sync
in classDefaultPromise<Void>
- Throws:
InterruptedException
-
cause
Description copied from interface:Future
Returns the cause of the failed I/O operation if the I/O operation has failed.- Specified by:
cause
in interfaceChannelGroupFuture
- Specified by:
cause
in interfaceFuture<Void>
- Overrides:
cause
in classDefaultPromise<Void>
- Returns:
- the cause of the failure.
null
if succeeded or this future is not completed yet.
-
setSuccess0
private void setSuccess0() -
setFailure0
-
setSuccess
Description copied from interface:Promise
Marks this future as a success and notifies all listeners. If it is success or failed already it will throw anIllegalStateException
.- Specified by:
setSuccess
in interfacePromise<Void>
- Overrides:
setSuccess
in classDefaultPromise<Void>
-
trySuccess
Description copied from interface:Promise
Marks this future as a success and notifies all listeners.- Specified by:
trySuccess
in interfacePromise<Void>
- Overrides:
trySuccess
in classDefaultPromise<Void>
- Returns:
true
if and only if successfully marked this future as a success. Otherwisefalse
because this future is already marked as either a success or a failure.
-
setFailure
Description copied from interface:Promise
Marks this future as a failure and notifies all listeners. If it is success or failed already it will throw anIllegalStateException
.- Specified by:
setFailure
in interfacePromise<Void>
- Overrides:
setFailure
in classDefaultPromise<Void>
-
tryFailure
Description copied from interface:Promise
Marks this future as a failure and notifies all listeners.- Specified by:
tryFailure
in interfacePromise<Void>
- Overrides:
tryFailure
in classDefaultPromise<Void>
- Returns:
true
if and only if successfully marked this future as a failure. Otherwisefalse
because this future is already marked as either a success or a failure.
-
checkDeadLock
protected void checkDeadLock()- Overrides:
checkDeadLock
in classDefaultPromise<Void>
-