[External] : Re: StructuredTaskScope and Futures
forax at univ-mlv.fr
forax at univ-mlv.fr
Wed Jan 4 15:54:03 UTC 2023
----- Original Message -----
> From: "Ron Pressler" <ron.pressler at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "loom-dev" <loom-dev at openjdk.org>
> Sent: Tuesday, January 3, 2023 12:00:45 PM
> Subject: Re: [External] : Re: StructuredTaskScope and Futures
>> On 3 Jan 2023, at 10:31, Remi Forax <forax at univ-mlv.fr> wrote:
>>
>> ----- Original Message -----
>>> From: "Ron Pressler" <ron.pressler at oracle.com>
>>> To: "loom-dev" <loom-dev at openjdk.org>
>>> Sent: Tuesday, January 3, 2023 11:21:15 AM
>>> Subject: StructuredTaskScope and Futures
>>
>>> Hi.
>>
>> Hi,
>> happy new year,
>>
>
> Happy new year!
>
>>>
>>> A question to those of you who have been using StructuredTaskScope: Have you
>>> ever used any method on the Future returned from fork other than resultNow and,
>>> if so, when/why?
>>
>> state() to know the result/cancellation/error and exceptionNow() to
>> propagate/log the error messages.
>>
>
>
> When do you need to know the state or exception on an individual task rather
> than rely on the policy to handle errors collectively before processing
> successful results? If you have a code example that would be helpful.
because you may want to log the suppressed exceptions.
Let say you use a ShutdownOnSuccess, even if you get a result, you still want to log all the exceptions that occurs before the result because some exceptions are triggered by an issue that should be fixed (an invalid auth key, an expired token, etc) which shows that even if it works, something had gone wrong.
Conceptually, we are looking at abstracting a loop over async calls, a shutdown on success is equivalent to a short-circuit of the loop.
Each call returns Result | Exception.
So all calls are a (Result1 | Exception1) x (Result2 | Exception2) x ...
If you reduce it, you get a Result x Exception.
>
> — Ron
Rémi
More information about the loom-dev
mailing list