in benchmarks/src/jmh/kotlin/benchmarks/scheduler/ForkJoinBenchmark.kt [123:144]
override fun compute() {
if (end - start <= BATCH_SIZE) {
rawResult = compute(coefficients, start, end)
} else {
pendingCount = 2
// One may fork only once here and executing second task here with looping over firstComplete to be even more efficient
first = RecursiveAction(
coefficients,
start,
start + (end - start) / 2,
parent = this
).fork()
second = RecursiveAction(
coefficients,
start + (end - start) / 2,
end,
parent = this
).fork()
}
tryComplete()
}