Class ExecutionSequencer
- java.lang.Object
-
- com.google.common.util.concurrent.ExecutionSequencer
-
@Beta public final class ExecutionSequencer extends java.lang.Object
Serializes execution of a set of operations. This class guarantees that a submitted callable will not be called before previously submitted callables (and anyFuture
s returned from them) have completed.This class implements a superset of the behavior of
MoreExecutors.newSequentialExecutor(java.util.concurrent.Executor)
. If your tasks all run on the same underlying executor and don't need to wait forFuture
s returned fromAsyncCallable
s, use it instead.- Since:
- 26.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ExecutionSequencer
create()
Creates a new instance.<T> ListenableFuture<T>
submit(java.util.concurrent.Callable<T> callable, java.util.concurrent.Executor executor)
Enqueues a task to run when the previous task (if any) completes.<T> ListenableFuture<T>
submitAsync(AsyncCallable<T> callable, java.util.concurrent.Executor executor)
Enqueues a task to run when the previous task (if any) completes.
-
-
-
Method Detail
-
create
public static ExecutionSequencer create()
Creates a new instance.
-
submit
public <T> ListenableFuture<T> submit(java.util.concurrent.Callable<T> callable, java.util.concurrent.Executor executor)
Enqueues a task to run when the previous task (if any) completes.Cancellation does not propagate from the output future to a callable that has begun to execute, but if the output future is cancelled before
Callable.call()
is invoked,Callable.call()
will not be invoked.
-
submitAsync
public <T> ListenableFuture<T> submitAsync(AsyncCallable<T> callable, java.util.concurrent.Executor executor)
Enqueues a task to run when the previous task (if any) completes.Cancellation does not propagate from the output future to the future returned from
callable
or a callable that has begun to execute, but if the output future is cancelled beforeAsyncCallable.call()
is invoked,AsyncCallable.call()
will not be invoked.
-
-