Class PrioritizedParallelExecutor
- java.lang.Object
-
- net.adoptopenjdk.icedteaweb.resources.PrioritizedParallelExecutor
-
public class PrioritizedParallelExecutor extends java.lang.ObjectExecutor which will execute multipleCallablesin 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 finalFuturewill complete as soon as the first callable completed successfully and all other callables with higher priority (if any) have completed exceptionally
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ExecutorServiceexecutorprivate static java.lang.StringLIST_PREFIX
-
Constructor Summary
Constructors Constructor Description PrioritizedParallelExecutor(java.util.concurrent.ExecutorService executor)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.ExceptiongetFailureReason(java.util.List<java.lang.Exception> exceptions)<V> java.util.concurrent.Future<V>getSuccessfulResultWithHighestPriority(java.util.List<java.util.concurrent.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.
-
-
-
Field Detail
-
LIST_PREFIX
private static final java.lang.String LIST_PREFIX
- See Also:
- Constant Field Values
-
executor
private final java.util.concurrent.ExecutorService executor
-
-
Method Detail
-
getSuccessfulResultWithHighestPriority
public <V> java.util.concurrent.Future<V> getSuccessfulResultWithHighestPriority(java.util.List<java.util.concurrent.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 returnedFuturewill 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 java.lang.Exception getFailureReason(java.util.List<java.lang.Exception> exceptions)
-
-