My experience with Structured Concurrency
David Alayachew
davidalayachew at gmail.com
Fri Aug 15 09:52:30 UTC 2025
Hello @loom-dev <loom-dev at openjdk.org>,
I just wanted to share my experience with Structured Concurrency. I had
actually been using it for a while now, but only recently got experience
with the new Joiner. After trying it out, my previously stated opinion has
changed.
Overall, Structured Concurrency has been a pleasure. I'll avoid repeating
ALL my old thoughts and just highlight the KEY details.
* Structured Concurrency is excellent for complex error-handling. Receiving
exceptions via the subtask makes all the error-handling less painful.
* Structured Concurrency makes nesting scopes a breeze, a task I
historically found very painful to do.
* Inheritance allows me to take an existing Scope (now Joiner), and modify
only what I need to in order to modify it for my use case. Great for
reusing old strategies in new ways.
Now for the new stuff -- having Joiner be the point of extension definitely
proved to be the right move imo. I didn't mention this in my original
message, but while it was easy to get a scope set up using inheritance, it
wasn't always clear what invariants needed to be maintained. For example,
the ensureOwnerAndJoined method. Was that something we needed to call when
inheriting? On which methods? Just join()?
The Joiner solution is comparatively simpler, which actually meant that I
ended up creating way more Joiners, rather than only several STS'. Joiners
invariants are obvious, and there is no ambiguity on what is expected from
the implementor.
Which, funnily enough, led to a slightly different problem -- I found
myself wanting an easier way to create Joiners. Since I was leaning on
Joiners so much more heavily than I was for STS, I ended up creating many
Joiners that do almost the same thing, with just minor variations. And
inheritance wasn't always the right answer, as I can't inherit from
multiple classes. Plus, most of my joiners were stateful, but I only wanted
the non-stateful parts of it. I could do composition, but it sort of felt
weird to delegate to multiple other Joiners.
Part of me kept wondering how well a factory method, similar to the ones
for Collectors and Gatherers, might fare for Joiners.
Regardless, even if we don't get that factory method, this library has been
a pleasure, and I can't wait to properly implement this once it goes live.
Thank you for your time and consideration.
David Alayachew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250815/8d9989f1/attachment-0001.htm>
More information about the loom-dev
mailing list