Package com.sk89q.worldedit.util.task
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>
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.sk89q.worldedit.util.task.Task
Task.State
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(Runnable listener, Executor executor) boolean
cancel
(boolean mayInterruptIfRunning) static <V> FutureForwardingTask<V>
Create a new instance.get()
Get the current percentage of completion.getState()
Get the state of the task.boolean
boolean
isDone()
Methods inherited from class com.sk89q.worldedit.util.task.AbstractTask
getCreationDate, getName, getOwner, getUniqueId
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
afterDone, interruptTask, pendingToString, set, setException, setFuture, toString, tryInternalFastPathGetFailure, wasInterrupted
-
Method Details
-
addListener
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
isCancelled
public boolean isCancelled()- Specified by:
isCancelled
in interfaceFuture<V>
- Overrides:
isCancelled
in classcom.google.common.util.concurrent.AbstractFuture<V>
-
isDone
public boolean isDone() -
get
- Specified by:
get
in interfaceFuture<V>
- Overrides:
get
in classcom.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 interfaceFuture<V>
- Overrides:
get
in classcom.google.common.util.concurrent.AbstractFuture<V>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
getState
Description copied from interface:Task
Get the state of the task.- Returns:
- the state of the task
-
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 futurename
- the name of the taskowner
- the owner of the task, ornull
- Returns:
- a new instance
-