Interface WriteFuture

  • All Superinterfaces:
    IoFuture
    All Known Implementing Classes:
    DefaultWriteFuture

    public interface WriteFuture
    extends IoFuture
    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)
     }
     
    Author:
    Apache MINA Project
    • Method Detail

      • isWritten

        boolean isWritten()
        Returns:
        true if the write operation is finished successfully.
      • getException

        Throwable getException()
        Returns:
        the cause of the write failure if and only if the write operation has failed due to an Exception. Otherwise, null is returned.
      • 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

        void setException​(Throwable cause)
        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
      • awaitUninterruptibly

        WriteFuture awaitUninterruptibly()
        Wait for the asynchronous operation to complete uninterruptibly. The attached listeners will be notified when the operation is completed.
        Specified by:
        awaitUninterruptibly in interface IoFuture
        Returns:
        the current IoFuture
      • addListener

        WriteFuture 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 interface IoFuture
        Parameters:
        listener - The listener to add
        Returns:
        the current IoFuture
      • removeListener

        WriteFuture removeListener​(IoFutureListener<?> listener)
        Removes an existing event listener so it won't be notified when the future is completed.
        Specified by:
        removeListener in interface IoFuture
        Parameters:
        listener - The listener to remove
        Returns:
        the current IoFuture