public interface WriteFuture extends IoFuture
IoFuture for asynchronous write requests.
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)
}
| 限定符和类型 | 方法和说明 |
|---|---|
WriteFuture |
addListener(IoFutureListener<?> listener)
Adds an event listener which is notified when
this future is completed.
|
WriteFuture |
await()
Wait for the asynchronous operation to complete.
|
WriteFuture |
awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly.
|
java.lang.Throwable |
getException() |
boolean |
isWritten() |
WriteFuture |
removeListener(IoFutureListener<?> listener)
Removes an existing event listener so it won't be notified when
the future is completed.
|
void |
setException(java.lang.Throwable cause)
Sets the cause of the write failure, and notifies all threads waiting
for this future.
|
void |
setWritten()
Sets the message is written, and notifies all threads waiting for
this future.
|
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, isDone, join, joinboolean isWritten()
java.lang.Throwable getException()
Exception. Otherwise,
null is returned.void setWritten()
void setException(java.lang.Throwable cause)
cause - The exception to store in the Future instanceWriteFuture await() throws java.lang.InterruptedException
await 在接口中 IoFutureWriteFuturejava.lang.InterruptedException - If the wait is interruptedWriteFuture awaitUninterruptibly()
awaitUninterruptibly 在接口中 IoFutureWriteFuture addListener(IoFutureListener<?> listener)
addListener 在接口中 IoFuturelistener - The listener to addWriteFuture removeListener(IoFutureListener<?> listener)
removeListener 在接口中 IoFuturelistener - The listener to remove