Structured concurrency: TaskHandle
forax at univ-mlv.fr
forax at univ-mlv.fr
Sat May 13 06:39:05 UTC 2023
----- Original Message -----
> From: "Alan Bateman" <Alan.Bateman at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "loom-dev" <loom-dev at openjdk.org>
> Sent: Saturday, May 13, 2023 8:28:51 AM
> Subject: Re: Structured concurrency: TaskHandle
> On 12/05/2023 22:54, forax at univ-mlv.fr wrote:
>> :
>> I'm thinking about the case where a user take a look at the state() after a call
>> to shutdown() followed by a call to join(),
>> see the example in my email to Ron.
>>
> In your example, the main task forks two subtasks, sleeps for 1ms, then
> calls shutdown. The first subtask is computing something, it may
> complete successfully before shutdown, it may not and thus its terminal
> state will be SUCCESS or CANCELLED. The second subtask sleeps for 1s
> before throwing an exception so it's likely terminal state is CANCELLED.
> I understand the example is contrived but I think I've missed your
> point. Are you talking about race in the older Future based
> implementation or are you talking about something with the updated
> API/implementation?
If i run it with JDK 20, it prints
java --add-modules=jdk.incubator.concurrent --enable-preview --source 20 StructuredConcurrencyTest.java
WARNING: Using incubator modules: jdk.incubator.concurrent
future 1: CANCELLED
future 2: FAILED
The second future does not report CANCELLED but FAILED, but perhaps there is an implementation bug somewhere ?
>
> -Alan
Rémi
More information about the loom-dev
mailing list