Feedback on structured concurrency

Alan Bateman alan.bateman at oracle.com
Tue Oct 22 09:16:30 UTC 2024


On 22/10/2024 08:56, Bart De Neuter wrote:
> As we are using structured concurrency in production, we would like to 
> give some feedback.
> We created an adapter 
> for java.util.concurrent.StructuredTaskScope.ShutdownOnFailure for the 
> following reasons:
>
>  1. To translate checked exceptions to a RuntimeException. The current
>     implementation throws an InterruptedException when calling the
>     join method which is a checked exception. This forces the code
>     that uses ShutdownOnFailure to handle the exception explicitly or
>     mark their method to throw this checked exception.
>  2. When calling join, our adapter changes the behaviour from the join
>     method to throw exceptions by default by calling throwIfFailed
>     under the hood. Our adapter provides an explicit method if a
>     developer doesn't want to have an exception thrown.
>

Remembering to use join().throwIfFailed() instead of join() is a hazard 
that goes away with the API refresh in the early access builds [1]. We 
re hoping to include this update for the next re-preview [2].

-Alan

[1] 
https://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/StructuredTaskScope.html
[2] https://openjdk.org/jeps/8340343
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20241022/4148fc48/attachment-0001.htm>


More information about the loom-dev mailing list