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 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, TimeUnit unit)
Wait for the asynchronous operation to complete with the specified timeout.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, TimeUnit unit)
Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.IoSession
getSession()
protected Object
getValue()
boolean
isDone()
void
join()
Deprecated.Replaced withawaitUninterruptibly()
.boolean
join(long timeoutMillis)
Deprecated.Replaced withawaitUninterruptibly(long)
.IoFuture
removeListener(IoFutureListener<?> listener)
Removes an existing event listener so it won't be notified when the future is completed.boolean
setValue(Object newValue)
Sets the result of the asynchronous operation, and mark it as finished.
-
-
-
Method Detail
-
getSession
public IoSession getSession()
- Specified by:
getSession
in interfaceIoFuture
- Returns:
- the
IoSession
which 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:
await
in 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 InterruptedException
Wait for the asynchronous operation to complete with the specified timeout.- Specified by:
await
in interfaceIoFuture
- Parameters:
timeout
- The maximum delay to wait before getting outunit
- the type of unit for the delay (seconds, minutes...)- Returns:
- true if the operation is completed.
- Throws:
InterruptedException
- If the thread is interrupted while waiting
-
await
public boolean await(long timeoutMillis) throws InterruptedException
Wait for the asynchronous operation to complete with the specified timeout.- Specified by:
await
in interfaceIoFuture
- Parameters:
timeoutMillis
- The maximum milliseconds to wait before getting out- Returns:
- true if 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:
awaitUninterruptibly
in 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:
awaitUninterruptibly
in interfaceIoFuture
- Parameters:
timeout
- The maximum delay to wait before getting outunit
- the type of unit for the delay (seconds, minutes...)- Returns:
- true if the operation is completed.
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.- Specified by:
awaitUninterruptibly
in interfaceIoFuture
- Parameters:
timeoutMillis
- The maximum milliseconds to wait before getting out- Returns:
- true if 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:
true
if the value has been set,false
if 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 event listener which is notified when this future is completed. If the listener is added after the completion, the listener is directly notified.- Specified by:
addListener
in interfaceIoFuture
- Parameters:
listener
- The listener to add- Returns:
- the current IoFuture
-
removeListener
public IoFuture removeListener(IoFutureListener<?> listener)
Removes an existing event listener so it won't be notified when the future is completed.- Specified by:
removeListener
in interfaceIoFuture
- Parameters:
listener
- The listener to remove- Returns:
- the current IoFuture
-
-