<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 5 Jan 2023, at 15:22, <a href="mailto:forax@univ-mlv.fr" class="">
forax@univ-mlv.fr</a> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">----- Original Message -----<br class="">
<blockquote type="cite" class="">From: "Ron Pressler" <<a href="mailto:ron.pressler@oracle.com" class="">ron.pressler@oracle.com</a>><br class="">
To: "Remi Forax" <<a href="mailto:forax@univ-mlv.fr" class="">forax@univ-mlv.fr</a>><br class="">
Cc: "loom-dev" <<a href="mailto:loom-dev@openjdk.java.net" class="">loom-dev@openjdk.java.net</a>><br class="">
Sent: Thursday, January 5, 2023 3:37:06 PM<br class="">
Subject: Re: [External] : API proposal for StructuredTaskScope<br class="">
</blockquote>
<br class="">
<blockquote type="cite" class="">We have considered such approaches.<br class="">
<br class="">
One glaring problem is the case of “heterogenous tasks”, i.e. tasks that each<br class="">
return a result of a different type. This is a very common scenario for<br class="">
ShutdownOnFailure.<br class="">
</blockquote>
<br class="">
I believe that using a static factory instead of a constructor (here StructuredTaskScope.of()) solve that pretty well.<br class="">
If no type is explicitly provided, the inference will default to Object which is exactly what you want in case of a shutdown on failure.</div>
</div>
</blockquote>
<br class="">
</div>
<div>I don’t follow. The scenario I had in mind is this:</div>
<div><br class="">
</div>
<div>
<div><font face="Courier New" class="">Response handle() throws ExecutionException, InterruptedException {</font></div>
<div><font face="Courier New" class="">    try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {</font></div>
<div><font face="Courier New" class="">        Future<String>  s1  = scope.fork(() -> fetchS1());</font></div>
<div><font face="Courier New" class="">        Future<String>  s2  = scope.fork(() -> fetchS2());</font></div>
<div><font face="Courier New" class="">        Future<Integer> i1  = scope.fork(() -> fetchI1());</font></div>
<div><font face="Courier New" class="">        Future<</font><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: "Courier New";" class="">Integer</span><font face="Courier New" class="">> i2  = scope.fork(() -> fetchI2());</font></div>
<div><font face="Courier New" class="">        </font></div>
<div><font face="Courier New" class="">        scope.join()</font><span style="font-family: "Courier New";" class="">.throwIfFailed();</span></div>
<div><font face="Courier New" class=""><br class="">
</font></div>
<div><font face="Courier New" class="">        return new Response(s1, s2, i1, i2);</font></div>
<div><font face="Courier New" class="">    }</font></div>
<div><font face="Courier New" class="">}</font></div>
<div><br class="">
</div>
<div>How do you propose to do it when fork returns void?</div>
<div><br class="">
</div>
<div>— Ron</div>
</div>
<div>
<div class=""><br class="">
</div>
</div>
</body>
</html>