Package org.apache.mina.core.future
Class DefaultIoFuture
- java.lang.Object
-
- org.apache.mina.core.future.DefaultIoFuture
-
- All Implemented Interfaces:
IoFuture
- Direct Known Subclasses:
AbstractIoService.ServiceOperationFuture,CompositeIoFuture,DefaultCloseFuture,DefaultConnectFuture,DefaultReadFuture,DefaultWriteFuture
public class DefaultIoFuture extends Object implements IoFuture
- Author:
- Apache MINA Project
-
-
Constructor Summary
Constructors Constructor Description DefaultIoFuture(IoSession session)Creates a new instance associated with anIoSession.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description IoFutureaddListener(IoFutureListener<?> listener)Adds an eventlistenerwhich is notified when this future is completed.IoFutureawait()Wait for the asynchronous operation to complete.booleanawait(long timeoutMillis)Wait for the asynchronous operation to complete with the specified timeout.booleanawait(long timeout, TimeUnit unit)Wait for the asynchronous operation to complete with the specified timeout.IoFutureawaitUninterruptibly()Wait for the asynchronous operation to complete uninterruptibly.booleanawaitUninterruptibly(long timeoutMillis)Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.booleanawaitUninterruptibly(long timeout, TimeUnit unit)Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.IoSessiongetSession()protected ObjectgetValue()booleanisDone()voidjoin()Deprecated.Replaced withawaitUninterruptibly().booleanjoin(long timeoutMillis)Deprecated.Replaced withawaitUninterruptibly(long).IoFutureremoveListener(IoFutureListener<?> listener)Removes an existing eventlistenerso it won't be notified when the future is completed.booleansetValue(Object newValue)Sets the result of the asynchronous operation, and mark it as finished.
-
-
-
Method Detail
-
getSession
public IoSession getSession()
- Specified by:
getSessionin interfaceIoFuture- Returns:
- the
IoSessionwhich is associated with this future.
-
join
@Deprecated public void join()
Deprecated.Replaced withawaitUninterruptibly().
-
join
@Deprecated public boolean join(long timeoutMillis)
Deprecated.Replaced withawaitUninterruptibly(long).
-
await
public IoFuture await() throws InterruptedException
Wait for the asynchronous operation to complete. The attached listeners will be notified when the operation is completed.- Specified by:
awaitin interfaceIoFuture- Returns:
- The instance of IoFuture that we are waiting for
- Throws:
InterruptedException- If the thread is interrupted while waiting
-
await
public boolean await(long timeout, TimeUnit unit) throws InterruptedExceptionWait for the asynchronous operation to complete with the specified timeout.- Specified by:
awaitin interfaceIoFuture- Parameters:
timeout- The maximum delay to wait before getting outunit- the type of unit for the delay (seconds, minutes...)- Returns:
trueif the operation is completed.- Throws:
InterruptedException- If the thread is interrupted while waiting
-
await
public boolean await(long timeoutMillis) throws InterruptedExceptionWait for the asynchronous operation to complete with the specified timeout.- Specified by:
awaitin interfaceIoFuture- Parameters:
timeoutMillis- The maximum milliseconds to wait before getting out- Returns:
trueif the operation is completed.- Throws:
InterruptedException- If the thread is interrupted while waiting
-
awaitUninterruptibly
public IoFuture awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly. The attached listeners will be notified when the operation is completed.- Specified by:
awaitUninterruptiblyin interfaceIoFuture- Returns:
- the current IoFuture
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeout, TimeUnit unit)Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.- Specified by:
awaitUninterruptiblyin interfaceIoFuture- Parameters:
timeout- The maximum delay to wait before getting outunit- the type of unit for the delay (seconds, minutes...)- Returns:
trueif the operation is completed.
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.- Specified by:
awaitUninterruptiblyin interfaceIoFuture- Parameters:
timeoutMillis- The maximum milliseconds to wait before getting out- Returns:
trueif the operation is finished.
-
isDone
public boolean isDone()
-
setValue
public boolean setValue(Object newValue)
Sets the result of the asynchronous operation, and mark it as finished.- Parameters:
newValue- The result to store into the Future- Returns:
trueif the value has been set,falseif the future already has a value (thus is in ready state)
-
getValue
protected Object getValue()
- Returns:
- the result of the asynchronous operation.
-
addListener
public IoFuture addListener(IoFutureListener<?> listener)
Adds an eventlistenerwhich is notified when this future is completed. If the listener is added after the completion, the listener is directly notified.- Specified by:
addListenerin interfaceIoFuture- Parameters:
listener- The listener to add- Returns:
- the current IoFuture
-
removeListener
public IoFuture removeListener(IoFutureListener<?> listener)
Removes an existing eventlistenerso it won't be notified when the future is completed.- Specified by:
removeListenerin interfaceIoFuture- Parameters:
listener- The listener to remove- Returns:
- the current IoFuture
-
-