public class DefaultDepsAwareExecutorWithLocalStack<T> extends Object
DepsAwareTask
. This executor will attempt to
maintain maximum concurrency, while completing dependencies of each supplied work first.
This implementation uses workers that keep a local stack of tasks to avoid contention in the global queue.
Modifier and Type | Field and Description |
---|---|
protected Future<?>[] |
workers |
protected BlockingDeque<TaskType> |
workQueue |
Modifier and Type | Method and Description |
---|---|
void |
close()
Shuts down the executor workers immediately.
|
com.facebook.buck.core.graph.transformation.executor.impl.DefaultDepsAwareTask<T> |
createTask(Callable<T> callable) |
com.facebook.buck.core.graph.transformation.executor.impl.DefaultDepsAwareTask<T> |
createThrowingTask(Callable<T> callable,
ThrowingSupplier<com.google.common.collect.ImmutableSet<com.facebook.buck.core.graph.transformation.executor.impl.DefaultDepsAwareTask<T>>,Exception> prereqSupplier,
ThrowingSupplier<com.google.common.collect.ImmutableSet<com.facebook.buck.core.graph.transformation.executor.impl.DefaultDepsAwareTask<T>>,Exception> depsSupplier) |
boolean |
isShutdown() |
static <U> DefaultDepsAwareExecutorWithLocalStack<U> |
of(int numberOfThreads)
Creates a
DefaultDepsAwareExecutor with given numberOfThreads . |
protected static void |
runWorker(com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareWorker<?> worker) |
protected static <TaskType extends com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareTask<?,TaskType>,V extends com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareWorker<TaskType>> |
startWorkers(ExecutorService executorService,
int parallelism,
LinkedBlockingDeque<TaskType> workQueue,
java.util.function.Function<LinkedBlockingDeque<TaskType>,V> workerFunction) |
Future<T> |
submit(TaskType task) |
com.google.common.collect.ImmutableList<Future<T>> |
submitAll(Collection<TaskType> tasks)
Same as
DepsAwareExecutor.submit(DepsAwareTask) except for multiple tasks. |
protected final BlockingDeque<TaskType extends com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareTask<T,TaskType>> workQueue
protected final Future<?>[] workers
public static <U> DefaultDepsAwareExecutorWithLocalStack<U> of(int numberOfThreads)
DefaultDepsAwareExecutor
with given numberOfThreads
.public com.facebook.buck.core.graph.transformation.executor.impl.DefaultDepsAwareTask<T> createThrowingTask(Callable<T> callable, ThrowingSupplier<com.google.common.collect.ImmutableSet<com.facebook.buck.core.graph.transformation.executor.impl.DefaultDepsAwareTask<T>>,Exception> prereqSupplier, ThrowingSupplier<com.google.common.collect.ImmutableSet<com.facebook.buck.core.graph.transformation.executor.impl.DefaultDepsAwareTask<T>>,Exception> depsSupplier)
DepsAwareTask
with two stages of dependency computationpublic com.facebook.buck.core.graph.transformation.executor.impl.DefaultDepsAwareTask<T> createTask(Callable<T> callable)
DepsAwareTask
that can be executed in this executorprotected static void runWorker(com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareWorker<?> worker)
public void close()
DepsAwareExecutor
DepsAwareExecutor
close
in interface DepsAwareExecutor<T,TaskType extends com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareTask<T,TaskType>>
close
in interface AutoCloseable
public boolean isShutdown()
isShutdown
in interface DepsAwareExecutor<T,TaskType extends com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareTask<T,TaskType>>
DepsAwareExecutor.close()
has been calledpublic Future<T> submit(TaskType task)
submit
in interface DepsAwareExecutor<T,TaskType extends com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareTask<T,TaskType>>
task
- the DepsAwareTask
to runpublic com.google.common.collect.ImmutableList<Future<T>> submitAll(Collection<TaskType> tasks)
DepsAwareExecutor
DepsAwareExecutor.submit(DepsAwareTask)
except for multiple tasks.submitAll
in interface DepsAwareExecutor<T,TaskType extends com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareTask<T,TaskType>>
protected static <TaskType extends com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareTask<?,TaskType>,V extends com.facebook.buck.core.graph.transformation.executor.impl.AbstractDepsAwareWorker<TaskType>> Future<?>[] startWorkers(ExecutorService executorService, int parallelism, LinkedBlockingDeque<TaskType> workQueue, java.util.function.Function<LinkedBlockingDeque<TaskType>,V> workerFunction)