Class FutureForwardingTask<V>

java.lang.Object
com.google.common.util.concurrent.internal.InternalFutureFailureAccess
com.google.common.util.concurrent.AbstractFuture<V>
com.sk89q.worldedit.util.task.AbstractTask<V>
com.sk89q.worldedit.util.task.FutureForwardingTask<V>
Type Parameters:
V - the type returned
All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<V>, ProgressObservable, Task<V>, Future<V>

public class FutureForwardingTask<V> extends AbstractTask<V>
A task that wraps a ListenableFuture.

Task.State.SCHEDULED is never returned because it is not possible to test whether the future has "started," so Task.State.RUNNING is returned in its place.

Use create(ListenableFuture, String, Object) to create a new instance.

  • Method Details

    • addListener

      public void addListener(Runnable listener, Executor executor)
      Specified by:
      addListener in interface com.google.common.util.concurrent.ListenableFuture<V>
      Overrides:
      addListener in class com.google.common.util.concurrent.AbstractFuture<V>
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      Specified by:
      cancel in interface Future<V>
      Overrides:
      cancel in class com.google.common.util.concurrent.AbstractFuture<V>
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Future<V>
      Overrides:
      isCancelled in class com.google.common.util.concurrent.AbstractFuture<V>
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface Future<V>
      Overrides:
      isDone in class com.google.common.util.concurrent.AbstractFuture<V>
    • get

      Specified by:
      get in interface Future<V>
      Overrides:
      get in class com.google.common.util.concurrent.AbstractFuture<V>
      Throws:
      InterruptedException
      ExecutionException
    • get

      public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
      Specified by:
      get in interface Future<V>
      Overrides:
      get in class com.google.common.util.concurrent.AbstractFuture<V>
      Throws:
      InterruptedException
      ExecutionException
      TimeoutException
    • getState

      public Task.State getState()
      Description copied from interface: Task
      Get the state of the task.
      Returns:
      the state of the task
    • getProgress

      public Progress getProgress()
      Description copied from interface: ProgressObservable
      Get the current percentage of completion.
      Returns:
      a progress object
    • create

      public static <V> FutureForwardingTask<V> create(com.google.common.util.concurrent.ListenableFuture<V> future, String name, @Nullable Object owner)
      Create a new instance.
      Type Parameters:
      V - the type returned by the future
      Parameters:
      future - the future
      name - the name of the task
      owner - the owner of the task, or null
      Returns:
      a new instance