Class PrioritizedParallelExecutor

java.lang.Object
net.adoptopenjdk.icedteaweb.resources.PrioritizedParallelExecutor

public class PrioritizedParallelExecutor extends Object
Executor which will execute multiple Callables in parallel. The callables must be sorted and have the highest priority callable as the first in list. Executions of lower priority are canceled as soon as a higher priority result has been successfully been returned. The final Future will complete as soon as the first callable completed successfully and all other callables with higher priority (if any) have completed exceptionally
  • Field Details

  • Constructor Details

    • PrioritizedParallelExecutor

      public PrioritizedParallelExecutor(ExecutorService executor)
      Constructor
      Parameters:
      executor - the executor service which is used for executing the callables.
  • Method Details

    • getSuccessfulResultWithHighestPriority

      public <V> Future<V> getSuccessfulResultWithHighestPriority(List<Callable<V>> callables)
      Executes the passed callables in parallel The callables must be sorted by priority with the highest priority as the first in list. Executions of lower priority are canceled as soon as a higher priority result has successfully been calculated. The returned Future will complete as soon as the first callable completed successfully and all other callables with higher priority (if any) have completed exceptionally.
      Parameters:
      callables - the callables to execute.
      Returns:
      a future holding the best result from all callables.
    • getFailureReason

      private Exception getFailureReason(List<Exception> exceptions)