Class DefaultIoFuture

    • 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 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:
        InterruptedException - If the thread is interrupted while waiting
      • await

        public boolean await​(long timeout,
                             TimeUnit unit)
                      throws 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:
        InterruptedException - If the thread is interrupted while waiting
      • await

        public boolean await​(long timeoutMillis)
                      throws 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:
        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,
                                            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​(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 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