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 defaultChannelGroupFutureimplementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDefaultChannelGroupFuture.DefaultEntry<K,V>
-
Field Summary
Fields Modifier and Type Field Description private ChannelFutureListenerchildListenerprivate intfailureCountprivate java.util.Map<Channel,ChannelFuture>futuresprivate ChannelGroupgroupprivate intsuccessCount
-
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 DefaultChannelGroupFutureaddListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)Adds the specified listener to this future.DefaultChannelGroupFutureaddListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)Adds the specified listeners to this future.DefaultChannelGroupFutureawait()Waits for this future to be completed.DefaultChannelGroupFutureawaitUninterruptibly()Waits for this future to be completed without interruption.ChannelGroupExceptioncause()Returns the cause of the failed I/O operation if the I/O operation has failed.protected voidcheckDeadLock()ChannelFuturefind(Channel channel)Returns theChannelFutureof the individual I/O operation which is associated with the specifiedChannel.ChannelGroupgroup()Returns theChannelGroupwhich is associated with this future.booleanisPartialFailure()Returnstrueif and only if the I/O operations associated with this future have failed partially with some success.booleanisPartialSuccess()Returnstrueif and only if the I/O operations associated with this future were partially successful with some failure.java.util.Iterator<ChannelFuture>iterator()Returns theIteratorthat enumerates allChannelFutures which are associated with this future.DefaultChannelGroupFutureremoveListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)Removes the first occurrence of the specified listener from this future.DefaultChannelGroupFutureremoveListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)Removes the first occurrence for each of the listeners from this future.DefaultChannelGroupFuturesetFailure(java.lang.Throwable cause)Marks this future as a failure and notifies all listeners.private voidsetFailure0(ChannelGroupException cause)DefaultChannelGroupFuturesetSuccess(java.lang.Void result)Marks this future as a success and notifies all listeners.private voidsetSuccess0()DefaultChannelGroupFuturesync()Waits for this future until it is done, and rethrows the cause of the failure if this future failed.DefaultChannelGroupFuturesyncUninterruptibly()Waits for this future until it is done, and rethrows the cause of the failure if this future failed.booleantryFailure(java.lang.Throwable cause)Marks this future as a failure and notifies all listeners.booleantrySuccess(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:ChannelGroupFutureReturns theChannelGroupwhich is associated with this future.- Specified by:
groupin interfaceChannelGroupFuture
-
find
public ChannelFuture find(Channel channel)
Description copied from interface:ChannelGroupFutureReturns theChannelFutureof the individual I/O operation which is associated with the specifiedChannel.- Specified by:
findin interfaceChannelGroupFuture- Returns:
- the matching
ChannelFutureif found.nullotherwise.
-
iterator
public java.util.Iterator<ChannelFuture> iterator()
Description copied from interface:ChannelGroupFutureReturns theIteratorthat enumerates allChannelFutures which are associated with this future. Please note that the returnedIteratoris is unmodifiable, which means aChannelFuturecannot be removed from this future.- Specified by:
iteratorin interfaceChannelGroupFuture- Specified by:
iteratorin interfacejava.lang.Iterable<ChannelFuture>
-
isPartialSuccess
public boolean isPartialSuccess()
Description copied from interface:ChannelGroupFutureReturnstrueif and only if the I/O operations associated with this future were partially successful with some failure.- Specified by:
isPartialSuccessin interfaceChannelGroupFuture
-
isPartialFailure
public boolean isPartialFailure()
Description copied from interface:ChannelGroupFutureReturnstrueif and only if the I/O operations associated with this future have failed partially with some success.- Specified by:
isPartialFailurein interfaceChannelGroupFuture
-
addListener
public DefaultChannelGroupFuture addListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Description copied from interface:FutureAdds 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:
addListenerin interfaceChannelGroupFuture- Specified by:
addListenerin interfaceFuture<java.lang.Void>- Specified by:
addListenerin interfacePromise<java.lang.Void>- Overrides:
addListenerin classDefaultPromise<java.lang.Void>
-
addListeners
public DefaultChannelGroupFuture addListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Description copied from interface:FutureAdds 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:
addListenersin interfaceChannelGroupFuture- Specified by:
addListenersin interfaceFuture<java.lang.Void>- Specified by:
addListenersin interfacePromise<java.lang.Void>- Overrides:
addListenersin classDefaultPromise<java.lang.Void>
-
removeListener
public DefaultChannelGroupFuture removeListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Description copied from interface:FutureRemoves 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:
removeListenerin interfaceChannelGroupFuture- Specified by:
removeListenerin interfaceFuture<java.lang.Void>- Specified by:
removeListenerin interfacePromise<java.lang.Void>- Overrides:
removeListenerin classDefaultPromise<java.lang.Void>
-
removeListeners
public DefaultChannelGroupFuture removeListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Description copied from interface:FutureRemoves 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:
removeListenersin interfaceChannelGroupFuture- Specified by:
removeListenersin interfaceFuture<java.lang.Void>- Specified by:
removeListenersin interfacePromise<java.lang.Void>- Overrides:
removeListenersin classDefaultPromise<java.lang.Void>
-
await
public DefaultChannelGroupFuture await() throws java.lang.InterruptedException
Description copied from interface:FutureWaits for this future to be completed.- Specified by:
awaitin interfaceChannelGroupFuture- Specified by:
awaitin interfaceFuture<java.lang.Void>- Specified by:
awaitin interfacePromise<java.lang.Void>- Overrides:
awaitin classDefaultPromise<java.lang.Void>- Throws:
java.lang.InterruptedException- if the current thread was interrupted
-
awaitUninterruptibly
public DefaultChannelGroupFuture awaitUninterruptibly()
Description copied from interface:FutureWaits for this future to be completed without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceChannelGroupFuture- Specified by:
awaitUninterruptiblyin interfaceFuture<java.lang.Void>- Specified by:
awaitUninterruptiblyin interfacePromise<java.lang.Void>- Overrides:
awaitUninterruptiblyin classDefaultPromise<java.lang.Void>
-
syncUninterruptibly
public DefaultChannelGroupFuture syncUninterruptibly()
Description copied from interface:FutureWaits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
syncUninterruptiblyin interfaceChannelGroupFuture- Specified by:
syncUninterruptiblyin interfaceFuture<java.lang.Void>- Specified by:
syncUninterruptiblyin interfacePromise<java.lang.Void>- Overrides:
syncUninterruptiblyin classDefaultPromise<java.lang.Void>
-
sync
public DefaultChannelGroupFuture sync() throws java.lang.InterruptedException
Description copied from interface:FutureWaits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
syncin interfaceChannelGroupFuture- Specified by:
syncin interfaceFuture<java.lang.Void>- Specified by:
syncin interfacePromise<java.lang.Void>- Overrides:
syncin classDefaultPromise<java.lang.Void>- Throws:
java.lang.InterruptedException
-
cause
public ChannelGroupException cause()
Description copied from interface:FutureReturns the cause of the failed I/O operation if the I/O operation has failed.- Specified by:
causein interfaceChannelGroupFuture- Specified by:
causein interfaceFuture<java.lang.Void>- Overrides:
causein classDefaultPromise<java.lang.Void>- Returns:
- the cause of the failure.
nullif 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:PromiseMarks this future as a success and notifies all listeners. If it is success or failed already it will throw anIllegalStateException.- Specified by:
setSuccessin interfacePromise<java.lang.Void>- Overrides:
setSuccessin classDefaultPromise<java.lang.Void>
-
trySuccess
public boolean trySuccess(java.lang.Void result)
Description copied from interface:PromiseMarks this future as a success and notifies all listeners.- Specified by:
trySuccessin interfacePromise<java.lang.Void>- Overrides:
trySuccessin classDefaultPromise<java.lang.Void>- Returns:
trueif and only if successfully marked this future as a success. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
setFailure
public DefaultChannelGroupFuture setFailure(java.lang.Throwable cause)
Description copied from interface:PromiseMarks this future as a failure and notifies all listeners. If it is success or failed already it will throw anIllegalStateException.- Specified by:
setFailurein interfacePromise<java.lang.Void>- Overrides:
setFailurein classDefaultPromise<java.lang.Void>
-
tryFailure
public boolean tryFailure(java.lang.Throwable cause)
Description copied from interface:PromiseMarks this future as a failure and notifies all listeners.- Specified by:
tryFailurein interfacePromise<java.lang.Void>- Overrides:
tryFailurein classDefaultPromise<java.lang.Void>- Returns:
trueif and only if successfully marked this future as a failure. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
checkDeadLock
protected void checkDeadLock()
- Overrides:
checkDeadLockin classDefaultPromise<java.lang.Void>
-
-