Interface WriteFuture
- All Superinterfaces:
IoFuture
- All Known Implementing Classes:
DefaultWriteFuture
An
IoFuture for asynchronous write requests.
Example
IoSession session = ...;
WriteFuture future = session.write(...);
// Wait until the message is completely written out to the O/S buffer.
future.awaitUninterruptibly();
if( future.isWritten() )
{
// The message has been written successfully.
}
else
{
// The message couldn't be written out completely for some reason.
// (e.g. Connection is closed)
}
-
Method Summary
Modifier and TypeMethodDescriptionaddListener(IoFutureListener<?> listener) Adds an eventlistenerwhich is notified when this future is completed.await()Wait for the asynchronous operation to complete.Wait for the asynchronous operation to complete uninterruptibly.booleanremoveListener(IoFutureListener<?> listener) Removes an existing eventlistenerso it won't be notified when the future is completed.voidsetException(Throwable cause) Sets the cause of the write failure, and notifies all threads waiting for this future.voidSets the message is written, and notifies all threads waiting for this future.Methods inherited from interface IoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, isDone, join, join
-
Method Details
-
isWritten
boolean isWritten()- Returns:
trueif the write operation is finished successfully.
-
getException
-
setWritten
void setWritten()Sets the message is written, and notifies all threads waiting for this future. This method is invoked by MINA internally. Please do not call this method directly. -
setException
Sets the cause of the write failure, and notifies all threads waiting for this future. This method is invoked by MINA internally. Please do not call this method directly.- Parameters:
cause- The exception to store in the Future instance
-
await
Wait for the asynchronous operation to complete. The attached listeners will be notified when the operation is completed.- Specified by:
awaitin interfaceIoFuture- Returns:
- the created
WriteFuture - Throws:
InterruptedException- If the wait is interrupted
-
awaitUninterruptibly
WriteFuture 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
-
addListener
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
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
-