[External] : Re: StructuredTaskScope and Futures

Alan Bateman Alan.Bateman at oracle.com
Wed Jan 4 17:03:36 UTC 2023


On 04/01/2023 16:48, Florian Schmaus wrote:
>
> I always wondered if it would be helpful if StructuredTaskScope had
>
> List<V> results()
> List<Throwable> exceptions()
>
> As Remi wrote, it is sometimes useful to inspect the failure cases, 
> e.g., to check if it was a sporadic or persistent failure. Similar, it 
> is sometimes good to have access to all results. For example to fall 
> back to other results in case a result is not usable.

The intention with StructuredTaskScope is that the API defines a small 
number of subclasses that implement common policies and for it to be 
easy to extend to implement whatever collection or policy is 
appropriate. The subclass is meant to define the methods that make 
available the results or other outcome. The "Extending 
StructuredTaskScope" section in the class description has an example 
that collects all results, and a method to get the results as a stream. 
Once we get more experience and feedback in this area then it might be 
that the two "built-in" policies that aren't the best but for now I 
think it should be easy to implement other policies.

Just to put more context on this discussion - the issue with fork 
returning Future is the temptation to call Future::get and wait for the 
result whereas the intention with this API is to wait in 
StructuredTaskScope::join and then process the results or outcome.

-Alan.


More information about the loom-dev mailing list