public class DefaultIoFuture extends java.lang.Object implements IoFuture
| Modifier and Type | Field and Description |
|---|---|
private static long |
DEAD_LOCK_CHECK_INTERVAL
A number of seconds to wait between two deadlock controls ( 5 seconds )
|
private IoFutureListener<?> |
firstListener |
private java.lang.Object |
lock
A lock used by the wait() method
|
private java.util.List<IoFutureListener<?>> |
otherListeners |
private boolean |
ready |
private java.lang.Object |
result |
private IoSession |
session
The associated session
|
private int |
waiters |
| Constructor and Description |
|---|
DefaultIoFuture(IoSession session)
Creates a new instance associated with an
IoSession. |
| Modifier and Type | Method and Description |
|---|---|
IoFuture |
addListener(IoFutureListener<?> listener)
Adds an event listener which is notified when
this future is completed.
|
IoFuture |
await()
Wait for the asynchronous operation to complete.
|
boolean |
await(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout.
|
boolean |
await(long timeout,
java.util.concurrent.TimeUnit unit)
Wait for the asynchronous operation to complete with the specified timeout.
|
private boolean |
await0(long timeoutMillis,
boolean interruptable)
Wait for the Future to be ready.
|
IoFuture |
awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly.
|
boolean |
awaitUninterruptibly(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout
uninterruptibly.
|
boolean |
awaitUninterruptibly(long timeout,
java.util.concurrent.TimeUnit unit)
Wait for the asynchronous operation to complete with the specified timeout
uninterruptibly.
|
private void |
checkDeadLock()
TODO checkDeadLock.
|
IoSession |
getSession()
Returns the
IoSession which is associated with this future. |
protected java.lang.Object |
getValue()
Returns the result of the asynchronous operation.
|
boolean |
isDone()
Returns if the asynchronous operation is completed.
|
void |
join()
Deprecated.
Replaced with
awaitUninterruptibly(). |
boolean |
join(long timeoutMillis)
Deprecated.
Replaced with
awaitUninterruptibly(long). |
private void |
notifyListener(IoFutureListener l) |
private void |
notifyListeners() |
IoFuture |
removeListener(IoFutureListener<?> listener)
Removes an existing event listener so it won't be notified when
the future is completed.
|
void |
setValue(java.lang.Object newValue)
Sets the result of the asynchronous operation, and mark it as finished.
|
private static final long DEAD_LOCK_CHECK_INTERVAL
private final IoSession session
private final java.lang.Object lock
private IoFutureListener<?> firstListener
private java.util.List<IoFutureListener<?>> otherListeners
private java.lang.Object result
private boolean ready
private int waiters
public IoSession getSession()
IoSession which is associated with this future.getSession in interface IoFuture@Deprecated public void join()
awaitUninterruptibly().@Deprecated public boolean join(long timeoutMillis)
awaitUninterruptibly(long).public IoFuture await() throws java.lang.InterruptedException
public boolean await(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
public boolean await(long timeoutMillis)
throws java.lang.InterruptedException
public IoFuture awaitUninterruptibly()
awaitUninterruptibly in interface IoFuturepublic boolean awaitUninterruptibly(long timeout,
java.util.concurrent.TimeUnit unit)
awaitUninterruptibly in interface IoFuturepublic boolean awaitUninterruptibly(long timeoutMillis)
awaitUninterruptibly in interface IoFutureprivate boolean await0(long timeoutMillis,
boolean interruptable)
throws java.lang.InterruptedException
timeoutMillis - The delay we will wait for the Future to be readyinterruptable - Tells if the wait can be interrupted or nottrue if the Future is readyjava.lang.InterruptedException - If the thread has been interrupted
when it's not allowed.private void checkDeadLock()
public boolean isDone()
public void setValue(java.lang.Object newValue)
protected java.lang.Object getValue()
public IoFuture addListener(IoFutureListener<?> listener)
addListener in interface IoFuturepublic IoFuture removeListener(IoFutureListener<?> listener)
removeListener in interface IoFutureprivate void notifyListeners()
private void notifyListener(IoFutureListener l)