Created
March 14, 2021 11:28
-
-
Save isopropylcyanide/c806dece64b7c1fe0a13831c689bc76c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ConcurrentWorkExecutor { | |
/** | |
* Splits a work iterable and submits each task into an executor where the task input is obtained by | |
* applying a mapper function. The intermediate non null results are joined until a {@code size} number | |
* of results are obtained post which they are collected using a custom user defined collector. | |
* | |
* @param size the number of results to wait for | |
* @param iterable the work represented as an iterable | |
* @param mapper the transformation of individual item U within the iterable to a result T | |
* @param collector the collection of T results obtained into a custom collector of type V | |
* @return an object of type V which is obtained after collection of intermediate T type results | |
* @implNote - If all intermediate results are required before collecting the final result, {@code size} | |
* must be equal to the number of items represented by the iterable | |
*/ | |
<T, U, V> V splitJoin(int size, | |
Iterable<U> iterable, | |
Function<U, T> mapper, | |
Collector<T, ?, V> collector | |
) throws ExecutionException, InterruptedException; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment