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 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

      private static final String CONCURRENCY_PROPERTY
      See Also:
    • log

      private static final org.slf4j.Logger log
    • executorService

      final ExecutorService executorService
  • Constructor Details

    • ConcurrentExecutor

      @Inject public ConcurrentExecutor()
  • Method Details

    • destroy

      @PreDestroy public void destroy()
      Destroy the internal thread pool.
    • submit

      public <R> FutureTask<R> submit(Callable<R> task)
    • awaiting

      public <R> Collector<FutureTask<R>, ?, List<R>> 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

      private <R> List<R> await(List<FutureTask<R>> scheduledTasks)
    • determineConcurrency

      static int determineConcurrency(int cpuCount)