Timeouts in structured concurrency
David Alayachew
davidalayachew at gmail.com
Fri Dec 19 08:33:14 UTC 2025
And maybe it'll help if I clarify what I was saying to @Holo The Sage Wolf
<holo3146 at gmail.com>.
Holo is saying that they like the default joiner, but adding a timeout to
it takes more code than necessary. They proposed multiple different
overloads, but I suggested the following overload instead.
StructuredTaskScope.open(UnaryOperator<StructuredTaskScope.Configuration>
configOperator)
This uses the default joiner, but allows easy config of things like timeout
or name. This is reasonable in my mind because most STS cases are "all or
nothing". They don't want to change the joining behaviour, just the name or
timeout. So, this is easy access to it.
Are you saying that this doesn't make sense, or there is something wrong
with it? Or maybe it's not worth the weight?
On Fri, Dec 19, 2025 at 3:14 AM David Alayachew <davidalayachew at gmail.com>
wrote:
> I don't understand your response to my quote @Alan Bateman
> <Alan.Bateman at oracle.com>.
>
> > We held back from adding a 1-arg open method that takes a configuration
> > function as it doubles down on the defaults.
>
> I don't understand -- are you saying that doubling down on the defaults is
> a bad thing, and that's why you held back? Why would doubling down on the
> defaults be bad?
>
> Or are you saying that you held back IN ORDER TO double down on the
> defaults? In which case, I understand what you mean by that even less.
>
> > We are confident that the "all of nothing" case is the most important
> > case, and this means the scope will be cancelled if any subtask fails.
> > It is harder to get a sense as to whether subtasks produce results of
> > the same type or different types, that is what determines if the default
> > is allSuccessfulOrThrow [1] or awaitAllSuccessfulOrThrow [2].
>
> The first sentence here makes sense (I even agree with you), but I don't
> see how it relates to the second sentence. Or how the second sentence is
> relevant to any part of my response.
>
> Did you maybe mean to respond to someone else besides me?
>
> On Fri, Dec 19, 2025 at 1:49 AM Alan Bateman <alan.bateman at oracle.com>
> wrote:
>
>>
>>
>> On 18/12/2025 21:00, David Alayachew wrote:
>> > :
>> >
>> > That said, if you dislike a 0 parameter call being forced into being a
>> > 2 paramefer call when you need to add timeout, then sure, I think
>> > adding an overload for that static method that takes in the
>> > configFunction is reasonable. I'd support that.
>> >
>> The no-arg open method is the only method uses the default configuration
>> and the "default" policy/joiner. We held back from adding a 1-arg open
>> method that takes a configuration function as it doubles down on the
>> defaults. We are confident that the "all of nothing" case is the most
>> important case, and this means the scope will be cancelled if any
>> subtask fails. It is harder to get a sense as to whether subtasks
>> produce results of the same type or different types, that is what
>> determines if the default is allSuccessfulOrThrow [1] or
>> awaitAllSuccessfulOrThrow [2].
>>
>> -Alan
>>
>> [1]
>>
>> https://download.java.net/java/early_access/jdk26/docs/api/java.base/java/util/concurrent/StructuredTaskScope.Joiner.html#allSuccessfulOrThrow()
>> [2]
>>
>> https://download.java.net/java/early_access/jdk26/docs/api/java.base/java/util/concurrent/StructuredTaskScope.Joiner.html#awaitAllSuccessfulOrThrow()
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20251219/11a8c9e8/attachment-0001.htm>
More information about the loom-dev
mailing list