[External] : Re: Future.resultNow / exceptionNow
Ron Pressler
ron.pressler at oracle.com
Mon Nov 22 23:00:27 UTC 2021
> On 22 Nov 2021, at 22:56, Ron Pressler <ron.pressler at oracle.com> wrote:
>
>
>
>> On 22 Nov 2021, at 21:44, Alex Otenko <oleksandr.otenko at gmail.com> wrote:
>>
>> Correct, hence the fuss around state != SUCCESS for the opposite condition.
>>
>> As for examples of when you'd need this - I think commonly I want to start processing the responses as soon as they start arriving, not wait for them all to complete.
>>
>> Maybe in this brave new world things just get expressed differently, but I would need something like "wait for the first" (that's "any" semantics), process, then "wait for the next", etc. Processing like this is more efficient than waiting for all, then process all, and less complex than processing each response in the task, as there is no concurrency in sequential processing of responses.
>>
>> Alex
>
> Have the completion handler (or the task itself) place the result into a blocking queue that you will then consume from the parent. There’s no need to poll futures.
>
> — Ron
P.S.
Just note that if you’re concerned about this level of efficiency, the “handle results as they come on a different thread” approach introduces a scheduling event (i.e. an unpack) for each completed task rather than just a single one when relying on join.
— Ron
More information about the loom-dev
mailing list