A shutdown task can still succeed ?

forax at univ-mlv.fr forax at univ-mlv.fr
Tue Feb 8 16:54:16 UTC 2022


----- Original Message -----
> From: "Alan Bateman" <Alan.Bateman at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>, "Ron Pressler" <ron.pressler at oracle.com>
> Cc: "loom-dev" <loom-dev at openjdk.java.net>
> Sent: Tuesday, February 8, 2022 5:20:26 PM
> Subject: Re: A shutdown task can still succeed ?

> On 08/02/2022 15:55, forax at univ-mlv.fr wrote:
>> :
>> I think i would prefer something like cancelOtherTasks() or stopOtherTasks()
>> than shutdown() because it is what shutdown does, it stops the completion of
>> the other tasks.
> 
> It's a bit more than that. As Ron said, it is more like the "the scope
> computation is done". It interrupts unfinished threads and prevents new
> threads from starting. It also causes join to wakeup as the main task
> has no reason to wait any longer.  In general I think it would be an
> advanced usage to call shutdown from a task. It is clearer to call
> shutdown from the handler method, after the task with the result has
> completed.

I see 4 different configurations,
- called in the handleComplete method (after the state of the task is set)
- called in one of the task (before the state() of the task is set)
- called in the scope before join()  (before or after the state() is set)
- called in the scope after join() (after the state() is set)

I would prefer the semantics to be cancel() all tasks that does not have a state set,
instead of making a specific case if shutdown() is called in a task or not.

> 
> -Alan.

Rémi


More information about the loom-dev mailing list