Class ConcurrentExecutor
java.lang.Object
io.github.ascopes.protobufmavenplugin.utils.ConcurrentExecutor
@Description("Manages an execution-wide thread pool for concurrent task execution")
@Named
public final class ConcurrentExecutor
extends Object
Helper component that allows scheduling IO-bound tasks within a thread pool.
- Since:
- 2.2.0
- Author:
- Ashley Scopes
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static int
private static int
private static int
(package private) final ExecutorService
private static final org.slf4j.Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate <R> List
<R> await
(List<FutureTask<R>> scheduledTasks) <R> Collector
<FutureTask<R>, ?, List<R>> awaiting()
Return a reactive collector of all the results of a stream of scheduled tasks.void
destroy()
Destroy the internal thread pool.(package private) static int
determineConcurrency
(int cpuCount) <R> FutureTask
<R>
-
Field Details
-
DEFAULT_MAXIMUM_CONCURRENCY
private static int DEFAULT_MAXIMUM_CONCURRENCY -
DEFAULT_MINIMUM_CONCURRENCY
private static int DEFAULT_MINIMUM_CONCURRENCY -
DEFAULT_CONCURRENCY_MULTIPLIER
private static int DEFAULT_CONCURRENCY_MULTIPLIER -
CONCURRENCY_PROPERTY
- See Also:
-
log
private static final org.slf4j.Logger log -
executorService
-
-
Constructor Details
-
ConcurrentExecutor
@Inject public ConcurrentExecutor()
-
-
Method Details
-
destroy
@PreDestroy public void destroy()Destroy the internal thread pool. -
submit
-
awaiting
Return a reactive collector of all the results of a stream of scheduled tasks.- Type Parameters:
R
- the task return type.- Returns:
- the collector.
- Throws:
MultipleFailuresException
- if any of the results raised exceptions. All results are collected prior to this being raised.
-
await
-
determineConcurrency
static int determineConcurrency(int cpuCount)
-