<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Alan Bateman" <alan.bateman@oracle.com><br><b>To: </b>"Remi Forax" <forax@univ-mlv.fr>, "loom-dev" <loom-dev@openjdk.java.net><br><b>Sent: </b>Wednesday, September 24, 2025 7:52:44 PM<br><b>Subject: </b>Re: Remark on the StructuredTaskScope API of Java 25<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><br>
    <br>
    <div class="moz-cite-prefix">On 24/09/2025 16:37, Remi Forax wrote:<br>
    </div>
    <blockquote cite="mid:715342229.35882407.1758728261503.JavaMail.zimbra@univ-eiffel.fr">
      <pre class="moz-quote-pre">:

And now two remarks,
 - is there a way to remove the limitation that the main thread (the one that have created the STS) can not access to SubTask.get(),
   because there is at least a case where i know that the task is finished before join() is called (see below).</pre>
    </blockquote>
    <br>
    This restriction is there to ensure that the API is used as
    intended. Subtasks are forked individually and then joined as a
    unit. If the API allowed Subtask::get to be used before join then it
    would be very fragile as it would be like a "wait-less" 
    Future::get. It might work sometimes, but if a subtask were slow
    then Subtask::get would throw ISE.</blockquote><div><br></div><div>In a way, i think i want something that the STS is not.</div><div><br data-mce-bogus="1"></div><div>I want to be able to run the semantics of onComplete() but without the burden of managing the concurrency part, like if onComplete() was run by the main thread (and yes, i know it has a cost).</div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><br>
    <br>
    <blockquote cite="mid:715342229.35882407.1758728261503.JavaMail.zimbra@univ-eiffel.fr">
      <pre class="moz-quote-pre"> - is there a way to get a joiner that returns the list of subtask in the order if their completeness, not in the order of onFork() ?

</pre>
    </blockquote>
    A Joiner can collect in its onComplete method so that will give you
    completion order. That said, I suspect you might be asking something
    different. Are you thinking about APIs such as CompletionService
    where you get a wakeup as subtasks complete rather join as a unit?</blockquote><div><br></div><div>CompletionService is several things, you can get the subtask as they complete (1), this is run by the main thread (2) and it's a pull API (3).</div><div><br data-mce-bogus="1"></div><div>I want (1) and (2), but not necessary (3), so it's still a STS that join as a unit.</div><div><br data-mce-bogus="1"></div><div>As said above, what i think i want is a way to opt-in to get onComplete to be run by the main thread when join() is called.</div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><br>
    <br>
    -Alan<br></blockquote><div><br></div><div>regards,</div><div>RĂ©mi</div><div><br data-mce-bogus="1"></div></div></div></body></html>