- All Implemented Interfaces:
Serializable,Future<Void>
A fork-join task that processes a range of integers from
lo to hi (exclusive)
in chunks of up to chunkSize.
Usage:
RangeTask.forEach(0,1000,10,(lo,hi)->{for(int i=lo;i<hi;i++) {....};});
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Constructor Summary
ConstructorsConstructorDescriptionRangeTask(int lo, int hi, int chunkSize, @NonNull BiConsumer<Integer, Integer> rangeConsumer, @NonNull CompletableFuture<Void> future) -
Method Summary
Modifier and TypeMethodDescriptionvoidcompute()static voidforEach(int lo, int hi, int chunkSize, BiConsumer<Integer, Integer> action) static CompletableFuture<Void> fork(int lo, int hi, int chunkSize, BiConsumer<Integer, Integer> action) voidonCompletion(CountedCompleter<?> caller) booleanonExceptionalCompletion(Throwable ex, CountedCompleter<?> caller) Methods inherited from class java.util.concurrent.CountedCompleter
addToPendingCount, compareAndSetPendingCount, complete, decrementPendingCountUnlessZero, exec, firstComplete, getCompleter, getPendingCount, getRawResult, getRoot, helpComplete, nextComplete, propagateCompletion, quietlyCompleteRoot, setPendingCount, setRawResult, tryCompleteMethods inherited from class java.util.concurrent.ForkJoinTask
adapt, adapt, adapt, adaptInterruptible, cancel, compareAndSetForkJoinTaskTag, completeExceptionally, exceptionNow, fork, get, get, getException, getForkJoinTaskTag, getPool, getQueuedTaskCount, getSurplusQueuedTaskCount, helpQuiesce, inForkJoinPool, invoke, invokeAll, invokeAll, invokeAll, isCancelled, isCompletedAbnormally, isCompletedNormally, isDone, join, peekNextLocalTask, pollNextLocalTask, pollSubmission, pollTask, quietlyComplete, quietlyInvoke, quietlyJoin, quietlyJoin, quietlyJoinUninterruptibly, reinitialize, resultNow, setForkJoinTaskTag, state, tryUnfork
-
Constructor Details
-
RangeTask
public RangeTask(int lo, int hi, int chunkSize, @NonNull BiConsumer<Integer, Integer> rangeConsumer, @NonNull CompletableFuture<Void> future)
-
-
Method Details
-
compute
public void compute()- Specified by:
computein classCountedCompleter<Void>
-
onCompletion
- Overrides:
onCompletionin classCountedCompleter<Void>
-
onExceptionalCompletion
- Overrides:
onExceptionalCompletionin classCountedCompleter<Void>
-
forEach
-
fork
public static CompletableFuture<Void> fork(int lo, int hi, int chunkSize, BiConsumer<Integer, Integer> action)
-