public interface DepsAwareExecutor<ResultType,TaskType extends DepsAwareTask<ResultType,TaskType>> extends AutoCloseable
DepsAwareTask
. This executor will attempt to
maintain maximum concurrency, while completing dependencies of each supplied work first.
It is guaranteed that the dependencies from DepsAwareTask.getDepsSupplier()
will be
completed before the work itself is executed.
In terms of thread safety, it is guaranteed that for the same DepsAwareTask
, its deps
supplier from DepsAwareTask.getDepsSupplier()
will be executed before its callable from
DepsAwareTask.getCallable()
is executed. That is, the supplier execution "happens before"
the callable execution, but potentially in different threads, where "happens before" is the
standard event ordering a -> b. There is an at least once guarantee on the number of invocations
of the deps supplier, and an exactly once guarantee on the callable. There is no guarantee of
synchronization between different instances of DepsAwareTask
other than that its
dependencies will be completed before the callable is evaluated.
Modifier and Type | Method and Description |
---|---|
void |
close()
Shuts down the executor workers immediately.
|
TaskType |
createTask(Callable<ResultType> callable) |
TaskType |
createThrowingTask(Callable<ResultType> callable,
ThrowingSupplier<com.google.common.collect.ImmutableSet<TaskType>,Exception> prereqSupplier,
ThrowingSupplier<com.google.common.collect.ImmutableSet<TaskType>,Exception> depsSupplier) |
boolean |
isShutdown() |
Future<ResultType> |
submit(TaskType task) |
com.google.common.collect.ImmutableList<Future<ResultType>> |
submitAll(Collection<TaskType> tasks)
Same as
submit(DepsAwareTask) except for multiple tasks. |
void close()
DepsAwareExecutor
close
in interface AutoCloseable
boolean isShutdown()
close()
has been calledTaskType createThrowingTask(Callable<ResultType> callable, ThrowingSupplier<com.google.common.collect.ImmutableSet<TaskType>,Exception> prereqSupplier, ThrowingSupplier<com.google.common.collect.ImmutableSet<TaskType>,Exception> depsSupplier)
DepsAwareTask
with two stages of dependency computationTaskType createTask(Callable<ResultType> callable)
DepsAwareTask
that can be executed in this executorFuture<ResultType> submit(TaskType task)
task
- the DepsAwareTask
to runcom.google.common.collect.ImmutableList<Future<ResultType>> submitAll(Collection<TaskType> tasks)
submit(DepsAwareTask)
except for multiple tasks.