Package org.jboss.netty.channel.group
Class DefaultChannelGroupFuture
- java.lang.Object
-
- org.jboss.netty.channel.group.DefaultChannelGroupFuture
-
- All Implemented Interfaces:
java.lang.Iterable<ChannelFuture>
,ChannelGroupFuture
public class DefaultChannelGroupFuture extends java.lang.Object implements ChannelGroupFuture
The defaultChannelGroupFuture
implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelFutureListener
childListener
private boolean
done
(package private) int
failureCount
private ChannelGroupFutureListener
firstListener
(package private) java.util.Map<java.lang.Integer,ChannelFuture>
futures
private ChannelGroup
group
private static InternalLogger
logger
private java.util.List<ChannelGroupFutureListener>
otherListeners
(package private) int
successCount
private int
waiters
-
Constructor Summary
Constructors Constructor Description DefaultChannelGroupFuture(ChannelGroup group, java.util.Collection<ChannelFuture> futures)
Creates a new instance.DefaultChannelGroupFuture(ChannelGroup group, java.util.Map<java.lang.Integer,ChannelFuture> futures)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(ChannelGroupFutureListener listener)
Adds the specified listener to this future.ChannelGroupFuture
await()
Waits for this future to be completed.boolean
await(long timeoutMillis)
Waits for this future to be completed within the specified time limit.boolean
await(long timeout, java.util.concurrent.TimeUnit unit)
Waits for this future to be completed within the specified time limit.private boolean
await0(long timeoutNanos, boolean interruptable)
ChannelGroupFuture
awaitUninterruptibly()
Waits for this future to be completed without interruption.boolean
awaitUninterruptibly(long timeoutMillis)
Waits for this future to be completed within the specified time limit without interruption.boolean
awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)
Waits for this future to be completed within the specified time limit without interruption.private static void
checkDeadLock()
ChannelFuture
find(java.lang.Integer channelId)
Returns theChannelFuture
of the individual I/O operation which is associated with theChannel
whose ID matches the specified integer.ChannelFuture
find(Channel channel)
Returns theChannelFuture
of the individual I/O operation which is associated with the specifiedChannel
.ChannelGroup
getGroup()
Returns theChannelGroup
which is associated with this future.boolean
isCompleteFailure()
Returnstrue
if and only if all I/O operations associated with this future have failed without any success.boolean
isCompleteSuccess()
Returnstrue
if and only if all I/O operations associated with this future were successful without any failure.boolean
isDone()
Returnstrue
if and only if this future is complete, regardless of whether the operation was successful, failed, or canceled.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.private void
notifyListener(ChannelGroupFutureListener l)
private void
notifyListeners()
void
removeListener(ChannelGroupFutureListener listener)
Removes the specified listener from this future.(package private) boolean
setDone()
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
group
private final ChannelGroup group
-
futures
final java.util.Map<java.lang.Integer,ChannelFuture> futures
-
firstListener
private ChannelGroupFutureListener firstListener
-
otherListeners
private java.util.List<ChannelGroupFutureListener> otherListeners
-
done
private boolean done
-
successCount
int successCount
-
failureCount
int failureCount
-
waiters
private int waiters
-
childListener
private final ChannelFutureListener childListener
-
-
Constructor Detail
-
DefaultChannelGroupFuture
public DefaultChannelGroupFuture(ChannelGroup group, java.util.Collection<ChannelFuture> futures)
Creates a new instance.
-
DefaultChannelGroupFuture
DefaultChannelGroupFuture(ChannelGroup group, java.util.Map<java.lang.Integer,ChannelFuture> futures)
-
-
Method Detail
-
getGroup
public ChannelGroup getGroup()
Description copied from interface:ChannelGroupFuture
Returns theChannelGroup
which is associated with this future.- Specified by:
getGroup
in interfaceChannelGroupFuture
-
find
public ChannelFuture find(java.lang.Integer channelId)
Description copied from interface:ChannelGroupFuture
Returns theChannelFuture
of the individual I/O operation which is associated with theChannel
whose ID matches the specified integer.- Specified by:
find
in interfaceChannelGroupFuture
- Returns:
- the matching
ChannelFuture
if found.null
otherwise.
-
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 is unmodifiable, which means aChannelFuture
cannot be removed from this future.- Specified by:
iterator
in interfaceChannelGroupFuture
- Specified by:
iterator
in interfacejava.lang.Iterable<ChannelFuture>
-
isDone
public boolean isDone()
Description copied from interface:ChannelGroupFuture
Returnstrue
if and only if this future is complete, regardless of whether the operation was successful, failed, or canceled.- Specified by:
isDone
in interfaceChannelGroupFuture
-
isCompleteSuccess
public boolean isCompleteSuccess()
Description copied from interface:ChannelGroupFuture
Returnstrue
if and only if all I/O operations associated with this future were successful without any failure.- Specified by:
isCompleteSuccess
in interfaceChannelGroupFuture
-
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
-
isCompleteFailure
public boolean isCompleteFailure()
Description copied from interface:ChannelGroupFuture
Returnstrue
if and only if all I/O operations associated with this future have failed without any success.- Specified by:
isCompleteFailure
in interfaceChannelGroupFuture
-
addListener
public void addListener(ChannelGroupFutureListener listener)
Description copied from interface:ChannelGroupFuture
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
-
removeListener
public void removeListener(ChannelGroupFutureListener listener)
Description copied from interface:ChannelGroupFuture
Removes the specified listener from this future. The specified listener is no longer notified when this future is done. If this future is already completed, this method has no effect and returns silently.- Specified by:
removeListener
in interfaceChannelGroupFuture
-
await
public ChannelGroupFuture await() throws java.lang.InterruptedException
Description copied from interface:ChannelGroupFuture
Waits for this future to be completed.- Specified by:
await
in interfaceChannelGroupFuture
- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
await
public boolean await(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Description copied from interface:ChannelGroupFuture
Waits for this future to be completed within the specified time limit.- Specified by:
await
in interfaceChannelGroupFuture
- Returns:
true
if and only if the future was completed within the specified time limit- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
await
public boolean await(long timeoutMillis) throws java.lang.InterruptedException
Description copied from interface:ChannelGroupFuture
Waits for this future to be completed within the specified time limit.- Specified by:
await
in interfaceChannelGroupFuture
- Returns:
true
if and only if the future was completed within the specified time limit- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
public ChannelGroupFuture awaitUninterruptibly()
Description copied from interface:ChannelGroupFuture
Waits for this future to be completed without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceChannelGroupFuture
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)
Description copied from interface:ChannelGroupFuture
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceChannelGroupFuture
- Returns:
true
if and only if the future was completed within the specified time limit
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeoutMillis)
Description copied from interface:ChannelGroupFuture
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceChannelGroupFuture
- Returns:
true
if and only if the future was completed within the specified time limit
-
await0
private boolean await0(long timeoutNanos, boolean interruptable) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
checkDeadLock
private static void checkDeadLock()
-
setDone
boolean setDone()
-
notifyListeners
private void notifyListeners()
-
notifyListener
private void notifyListener(ChannelGroupFutureListener l)
-
-