public interface ReadFuture extends IoFuture
IoFuture for asynchronous read requests.
IoSession session = ...;
// useReadOperation must be enabled to use read operation.
session.getConfig().setUseReadOperation(true);
ReadFuture future = session.read();
// Wait until a message is received.
future.awaitUninterruptibly();
try {
Object message = future.getMessage();
} catch (Exception e) {
...
}
| Modifier and Type | Method and Description |
|---|---|
ReadFuture |
addListener(IoFutureListener<?> listener)
Adds an event
listener which is notified when
this future is completed. |
ReadFuture |
await()
Wait for the asynchronous operation to complete.
|
ReadFuture |
awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly.
|
Throwable |
getException() |
Object |
getMessage()
Get the read message.
|
boolean |
isClosed() |
boolean |
isRead() |
ReadFuture |
removeListener(IoFutureListener<?> listener)
Removes an existing event
listener so it won't be notified when
the future is completed. |
void |
setClosed()
Sets the associated
IoSession is closed. |
void |
setException(Throwable cause)
Sets the cause of the read failure, and notifies all threads waiting
for this future.
|
void |
setRead(Object message)
Sets the message is written, and notifies all threads waiting for
this future.
|
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, isDone, join, joinObject getMessage()
null if this
future is not ready or the associated IoSession has been closed.boolean isRead()
true if a message was received successfully.boolean isClosed()
true if the IoSession associated with this
future has been closed.Throwable getException()
Exception. Otherwise,
null is returned.void setRead(Object message)
message - The received message to store in this futurevoid setClosed()
IoSession is closed. This method is invoked
by MINA internally. Please do not call this method directly.void setException(Throwable cause)
cause - The exception to store in the Future instanceReadFuture await() throws InterruptedException
await in interface IoFutureInterruptedException - If the thread is interrupted while waitingReadFuture awaitUninterruptibly()
awaitUninterruptibly in interface IoFutureReadFuture addListener(IoFutureListener<?> listener)
listener which is notified when
this future is completed. If the listener is added
after the completion, the listener is directly notified.addListener in interface IoFuturelistener - The listener to addReadFuture removeListener(IoFutureListener<?> listener)
listener so it won't be notified when
the future is completed.removeListener in interface IoFuturelistener - The listener to removeCopyright © 2004–2024 Apache MINA Project. All rights reserved.