Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8367858

Implement JEP xxx: Structured Concurrency (Sixth Preview)

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P3 P3
    • 26
    • core-libs
    • None
    • source, behavioral
    • minimal
    • Joiner is no longer a `@FunctionalInterface`. It's possible that there are custom `Joiner` implementations that use a lambda and return a fixed result. If so, they will need to be update.
    • Java API
    • SE

      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 invoke Joiner::onTimeout if a timeout is configured and the timeout expires before or while waiting. The onTimeout throws TimeoutException or may do nothing. This allows for Joiner implementation that are capable of returning a result from the subtasks that complete before the timeout expires.

      • Joiner.allUntil(Predicate) is changed to allow join 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-arg open is changed from Function<Configuration, Configuration> to UnaryOperator<Configuration>.

      Specification

      API diffs (generated by apidiff tool) are attached

            alanb Alan Bateman
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: