<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Yes. A sensible analogy to STS cancellation is "short-circuiting" in the Stream operations sense. It means that there's a valid result before all tasks have completed.</div>
<div class="elementToProof" id="Signature">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Cheers,<br>
¡Ô</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<b><br>
</b></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<b>Viktor Klang</b></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Software Architect, Java Platform Group<br>
Oracle</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Alan Bateman <alan.bateman@oracle.com><br>
<b>Sent:</b> Friday, 26 September 2025 18:35<br>
<b>To:</b> Adam Warski <adam@warski.org>; loom-dev@openjdk.org <loom-dev@openjdk.org><br>
<b>Cc:</b> Viktor Klang <viktor.klang@oracle.com><br>
<b>Subject:</b> Re: Problem report on the usage of Structured Concurrency (5th preview)</font>
<div> </div>
</div>
<div><br>
<br>
<div class="x_moz-cite-prefix">On 26/09/2025 14:04, Viktor Klang wrote:<br>
</div>
<blockquote type="cite"><style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>:
<div class="x_elementToProof" style="line-height:18px; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="line-height:18px; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
>If the main scope body includes any blocking logic, it might end up hanging indefinitely, while all the other forks have been cancelled.</div>
<div class="x_elementToProof" style="line-height:18px; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="line-height:18px; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
That statement is true by definition¡Xany code which is blocking indefinitely and is not interrupted, is by definition blocking indefinitely. </div>
<div class="x_elementToProof" style="line-height:18px; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="line-height:18px; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
>The main scope¡¦s body awaits for data from either of them (on a queue), and when an element is produced, sends it downstream. Now, if we¡¦re not careful with error handling, an exception in one of the substreams will cancel the scope, but the main scope will
 indefinitely wait on data, not aware of the error.</div>
<div class="x_elementToProof" style="line-height:18px; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="line-height:18px; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
This sounds, to me, like another issue with an absent feature¡XInter-task communication channels.</div>
</blockquote>
<br>
I agree, this example would be a good fit for channels.<br>
<br>
On interrupting the main task ("Non-uniform cancellation" section in the article), it's a good topic to discuss. When the scope is cancelled then the outstanding subtasks are interrupted so that they finish up quickly (their results aren't needed). It would
 mostly wrong to interrupt the main task as you aren't looking for the main task to finish, instead you want the main task to wakeup (from join) to process the outcome. It's important to say that cancellation does not mean failure, it just means there is an
 outcome, e.g. anyResultOrThrow cancels after any subtask completes successfully. A lengthy/looping forking phase can use isCancelled to avoid doing unnecessary work if needed. (Early prototypes did interrupt the main task but this was problematic on many levels
 and adds booking overhead to ensure that the processing of that interrupt is restricted to code in the block.)<br>
<br>
-Alan<br>
</div>
</body>
</html>