Summary
Small updates to java.util.concurrent.StructuredTaskScope
accumulated since JEP 505 / JDK 25.
Problem
There are use-cases where it can be useful to get a result when a timeout occurs. The existing API always throws a TimeoutException
if the timeout expires while (or before) waiting in join.
The join
method is currently hostile to cases where code wants to catch InterruptedException
and invoke join
again.
Solution
The API changes in this update are:
The
join
method is changed to invokeJoiner::onTimeout
if a timeout is configured and the timeout expires before or while waiting. TheonTimeout
throwsTimeoutException
or may do nothing. This allows forJoiner
implementation that are capable of returning a result from the subtasks that complete before the timeout expires.Joiner.allUntil(Predicate)
is changed to allowjoin
return the stream of all forked subtasks when the timeout expires.The
join
is now specified so that it may be called again if interrupted.Joiner
is no longer a@FunctionalInterface
The
configFunction
parameter to the 3-argopen
is changed fromFunction<Configuration, Configuration>
toUnaryOperator<Configuration>
.
Specification
API diffs (generated by apidiff
tool) are attached
- csr of
-
JDK-8367857 Implement JEP xxx: Structured Concurrency (Sixth Preview)
-
- Open
-