Class ForwardingFuture<V>

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ForwardingFuture()
      Constructor for use by subclasses.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel​(boolean mayInterruptIfRunning)
      Attempts to cancel execution of this task.
      protected abstract <? extends V> delegate()
      Returns the backing delegate instance that methods are forwarded to.
      V get()
      Waits if necessary for the computation to complete, and then retrieves its result.
      V get​(long timeout,  unit)
      Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
      boolean isCancelled()
      Returns true if this task was cancelled before it completed normally.
      boolean isDone()
      Returns true if this task completed.
      • Methods inherited from class java.lang.

        , , , , , , , , ,
    • Constructor Detail

      • ForwardingFuture

        protected ForwardingFuture()
        Constructor for use by subclasses.
    • Method Detail

      • delegate

        protected abstract <? extends Vdelegate()
        Description copied from class: ForwardingObject
        Returns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such as ForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.
        Specified by:
        delegate in class ForwardingObject
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Description copied from interface: 
        Attempts to cancel execution of this task. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task should be interrupted in an attempt to stop the task.

        After this method returns, subsequent calls to will always return true. Subsequent calls to will always return true if this method returned true.

        Specified by:
         in interface <V>
        Parameters:
        mayInterruptIfRunning - true if the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to complete
        Returns:
        false if the task could not be cancelled, typically because it has already completed normally; true otherwise
      • isCancelled

        public boolean isCancelled()
        Description copied from interface: 
        Returns true if this task was cancelled before it completed normally.
        Specified by:
         in interface <V>
        Returns:
        true if this task was cancelled before it completed
      • isDone

        public boolean isDone()
        Description copied from interface: 
        Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.
        Specified by:
         in interface <V>
        Returns:
        true if this task completed
      • get

        public V get()
              throws ,
                     
        Description copied from interface: 
        Waits if necessary for the computation to complete, and then retrieves its result.
        Specified by:
         in interface <V>
        Returns:
        the computed result
        Throws:
        - if the current thread was interrupted while waiting
        - if the computation threw an exception
      • get

        public V get​(long timeout,
                      unit)
              throws ,
                     ,
                     
        Description copied from interface: 
        Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
        Specified by:
         in interface <V>
        Parameters:
        timeout - the maximum time to wait
        unit - the time unit of the timeout argument
        Returns:
        the computed result
        Throws:
        - if the current thread was interrupted while waiting
        - if the computation threw an exception
        - if the wait timed out