Package io.netty.channel.group
Class DefaultChannelGroupFuture
- java.lang.Object
-
- io.netty.util.concurrent.AbstractFuture<V>
-
- io.netty.util.concurrent.DefaultPromise<java.lang.Void>
-
- io.netty.channel.group.DefaultChannelGroupFuture
-
- All Implemented Interfaces:
ChannelGroupFuture
,Future<java.lang.Void>
,Promise<java.lang.Void>
,java.lang.Iterable<ChannelFuture>
,java.util.concurrent.Future<java.lang.Void>
final class DefaultChannelGroupFuture extends DefaultPromise<java.lang.Void> implements ChannelGroupFuture
The defaultChannelGroupFuture
implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DefaultChannelGroupFuture.DefaultEntry<K,V>
-
Field Summary
Fields Modifier and Type Field Description private ChannelFutureListener
childListener
private int
failureCount
private java.util.Map<Channel,ChannelFuture>
futures
private ChannelGroup
group
private int
successCount
-
Constructor Summary
Constructors Constructor Description DefaultChannelGroupFuture(ChannelGroup group, java.util.Collection<ChannelFuture> futures, EventExecutor executor)
Creates a new instance.DefaultChannelGroupFuture(ChannelGroup group, java.util.Map<Channel,ChannelFuture> futures, EventExecutor executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultChannelGroupFuture
addListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Adds the specified listener to this future.DefaultChannelGroupFuture
addListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Adds the specified listeners to this future.DefaultChannelGroupFuture
await()
Waits for this future to be completed.DefaultChannelGroupFuture
awaitUninterruptibly()
Waits for this future to be completed without interruption.ChannelGroupException
cause()
Returns the cause of the failed I/O operation if the I/O operation has failed.protected void
checkDeadLock()
ChannelFuture
find(Channel channel)
Returns theChannelFuture
of the individual I/O operation which is associated with the specifiedChannel
.ChannelGroup
group()
Returns theChannelGroup
which is associated with this future.boolean
isPartialFailure()
Returnstrue
if and only if the I/O operations associated with this future have failed partially with some success.boolean
isPartialSuccess()
Returnstrue
if and only if the I/O operations associated with this future were partially successful with some failure.java.util.Iterator<ChannelFuture>
iterator()
Returns theIterator
that enumerates allChannelFuture
s which are associated with this future.DefaultChannelGroupFuture
removeListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Removes the first occurrence of the specified listener from this future.DefaultChannelGroupFuture
removeListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Removes the first occurrence for each of the listeners from this future.DefaultChannelGroupFuture
setFailure(java.lang.Throwable cause)
Marks this future as a failure and notifies all listeners.private void
setFailure0(ChannelGroupException cause)
DefaultChannelGroupFuture
setSuccess(java.lang.Void result)
Marks this future as a success and notifies all listeners.private void
setSuccess0()
DefaultChannelGroupFuture
sync()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.DefaultChannelGroupFuture
syncUninterruptibly()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.boolean
tryFailure(java.lang.Throwable cause)
Marks this future as a failure and notifies all listeners.boolean
trySuccess(java.lang.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
-
-
-
-
Field Detail
-
group
private final ChannelGroup group
-
futures
private final java.util.Map<Channel,ChannelFuture> futures
-
successCount
private int successCount
-
failureCount
private int failureCount
-
childListener
private final ChannelFutureListener childListener
-
-
Constructor Detail
-
DefaultChannelGroupFuture
DefaultChannelGroupFuture(ChannelGroup group, java.util.Collection<ChannelFuture> futures, EventExecutor executor)
Creates a new instance.
-
DefaultChannelGroupFuture
DefaultChannelGroupFuture(ChannelGroup group, java.util.Map<Channel,ChannelFuture> futures, EventExecutor executor)
-
-
Method Detail
-
group
public ChannelGroup group()
Description copied from interface:ChannelGroupFuture
Returns theChannelGroup
which is associated with this future.- Specified by:
group
in interfaceChannelGroupFuture
-
find
public ChannelFuture find(Channel channel)
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
public java.util.Iterator<ChannelFuture> 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 interfacejava.lang.Iterable<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 java.lang.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<java.lang.Void>
- Specified by:
addListener
in interfacePromise<java.lang.Void>
- Overrides:
addListener
in classDefaultPromise<java.lang.Void>
-
addListeners
public DefaultChannelGroupFuture addListeners(GenericFutureListener<? extends Future<? super java.lang.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<java.lang.Void>
- Specified by:
addListeners
in interfacePromise<java.lang.Void>
- Overrides:
addListeners
in classDefaultPromise<java.lang.Void>
-
removeListener
public DefaultChannelGroupFuture removeListener(GenericFutureListener<? extends Future<? super java.lang.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<java.lang.Void>
- Specified by:
removeListener
in interfacePromise<java.lang.Void>
- Overrides:
removeListener
in classDefaultPromise<java.lang.Void>
-
removeListeners
public DefaultChannelGroupFuture removeListeners(GenericFutureListener<? extends Future<? super java.lang.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<java.lang.Void>
- Specified by:
removeListeners
in interfacePromise<java.lang.Void>
- Overrides:
removeListeners
in classDefaultPromise<java.lang.Void>
-
await
public DefaultChannelGroupFuture await() throws java.lang.InterruptedException
Description copied from interface:Future
Waits for this future to be completed.- Specified by:
await
in interfaceChannelGroupFuture
- Specified by:
await
in interfaceFuture<java.lang.Void>
- Specified by:
await
in interfacePromise<java.lang.Void>
- Overrides:
await
in classDefaultPromise<java.lang.Void>
- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
public DefaultChannelGroupFuture 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<java.lang.Void>
- Specified by:
awaitUninterruptibly
in interfacePromise<java.lang.Void>
- Overrides:
awaitUninterruptibly
in classDefaultPromise<java.lang.Void>
-
syncUninterruptibly
public DefaultChannelGroupFuture 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<java.lang.Void>
- Specified by:
syncUninterruptibly
in interfacePromise<java.lang.Void>
- Overrides:
syncUninterruptibly
in classDefaultPromise<java.lang.Void>
-
sync
public DefaultChannelGroupFuture sync() throws java.lang.InterruptedException
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<java.lang.Void>
- Specified by:
sync
in interfacePromise<java.lang.Void>
- Overrides:
sync
in classDefaultPromise<java.lang.Void>
- Throws:
java.lang.InterruptedException
-
cause
public ChannelGroupException 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<java.lang.Void>
- Overrides:
cause
in classDefaultPromise<java.lang.Void>
- Returns:
- the cause of the failure.
null
if succeeded or this future is not completed yet.
-
setSuccess0
private void setSuccess0()
-
setFailure0
private void setFailure0(ChannelGroupException cause)
-
setSuccess
public DefaultChannelGroupFuture setSuccess(java.lang.Void result)
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<java.lang.Void>
- Overrides:
setSuccess
in classDefaultPromise<java.lang.Void>
-
trySuccess
public boolean trySuccess(java.lang.Void result)
Description copied from interface:Promise
Marks this future as a success and notifies all listeners.- Specified by:
trySuccess
in interfacePromise<java.lang.Void>
- Overrides:
trySuccess
in classDefaultPromise<java.lang.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
public DefaultChannelGroupFuture setFailure(java.lang.Throwable cause)
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<java.lang.Void>
- Overrides:
setFailure
in classDefaultPromise<java.lang.Void>
-
tryFailure
public boolean tryFailure(java.lang.Throwable cause)
Description copied from interface:Promise
Marks this future as a failure and notifies all listeners.- Specified by:
tryFailure
in interfacePromise<java.lang.Void>
- Overrides:
tryFailure
in classDefaultPromise<java.lang.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<java.lang.Void>
-
-