Class DefaultIoFuture

    • 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, java.util.concurrent.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, java.util.concurrent.TimeUnit unit)
      Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
      IoSession getSession()
      protected java.lang.Object getValue()  
      boolean isDone()
      void join()
      Deprecated.
      Replaced with awaitUninterruptibly().
      boolean join​(long timeoutMillis)
      Deprecated.
      IoFuture removeListener​(IoFutureListener<?> listener)
      Removes an existing event listener so it won't be notified when the future is completed.
      boolean setValue​(java.lang.Object newValue)
      Sets the result of the asynchronous operation, and mark it as finished.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultIoFuture

        public DefaultIoFuture​(IoSession session)
        Creates a new instance associated with an IoSession.
        Parameters:
        session - an IoSession which is associated with this future
    • Method Detail

      • join

        @Deprecated
        public boolean join​(long timeoutMillis)
        Deprecated.
        Specified by:
        join in interface IoFuture
        Parameters:
        timeoutMillis - The time to wait for the join before bailing out
        Returns:
        true if the join was successful
      • await

        public IoFuture await()
                       throws java.lang.InterruptedException
        Wait for the asynchronous operation to complete. The attached listeners will be notified when the operation is completed.
        Specified by:
        await in interface IoFuture
        Returns:
        The instance of IoFuture that we are waiting for
        Throws:
        java.lang.InterruptedException - If the thread is interrupted while waiting
      • await

        public boolean await​(long timeout,
                             java.util.concurrent.TimeUnit unit)
                      throws java.lang.InterruptedException
        Wait for the asynchronous operation to complete with the specified timeout.
        Specified by:
        await in interface IoFuture
        Parameters:
        timeout - The maximum delay to wait before getting out
        unit - the type of unit for the delay (seconds, minutes...)
        Returns:
        true if the operation is completed.
        Throws:
        java.lang.InterruptedException - If the thread is interrupted while waiting
      • await

        public boolean await​(long timeoutMillis)
                      throws java.lang.InterruptedException
        Wait for the asynchronous operation to complete with the specified timeout.
        Specified by:
        await in interface IoFuture
        Parameters:
        timeoutMillis - The maximum milliseconds to wait before getting out
        Returns:
        true if the operation is completed.
        Throws:
        java.lang.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 interface IoFuture
        Returns:
        the current IoFuture
      • awaitUninterruptibly

        public boolean awaitUninterruptibly​(long timeout,
                                            java.util.concurrent.TimeUnit unit)
        Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
        Specified by:
        awaitUninterruptibly in interface IoFuture
        Parameters:
        timeout - The maximum delay to wait before getting out
        unit - 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 interface IoFuture
        Parameters:
        timeoutMillis - The maximum milliseconds to wait before getting out
        Returns:
        true if the operation is finished.
      • isDone

        public boolean isDone()
        Specified by:
        isDone in interface IoFuture
        Returns:
        true if the operation is completed.
      • setValue

        public boolean setValue​(java.lang.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 java.lang.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 interface IoFuture
        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 interface IoFuture
        Parameters:
        listener - The listener to remove
        Returns:
        the current IoFuture