[External] : Re: A new build and a new structured concurrency API
Alex Otenko
oleksandr.otenko at gmail.com
Fri Nov 19 09:00:51 UTC 2021
I think I understand what problem onComplete is solving.
Basically, everything you want can be done in finally clause of the task,
except cancel all - because that's going to kill the task that calls it.
"Cancel all except me" is hard to implement. So you want something like a
finally, but which gets invoked after the task's Future has settled.
Yes, if you limit the functionality of onComplete to conditionally cancel
all, then there is no need to invoke it after having cancelled all once -
after all, can't un-cancel, and we limit its purpose to just cancellation
of all, no other aggregation, clean up or introspection of the finished
tasks.
Alex
On Thu, 18 Nov 2021, 17:12 Alan Bateman, <Alan.Bateman at oracle.com> wrote:
> On 18/11/2021 16:43, Alex Otenko wrote:
> > Yes, that's the behaviour that I expect, hence the question. Since
> > shutdown makes the Futures behave like a cancel was called, why is
> > onComplete singled out, and doesn't behave like when the Future got
> > cancelled - i.e. is not guaranteed to be invoked on shutdown, even
> > though guaranteed to be invoked on Future.cancel
>
> That's not the intention. If you invoke Future.cancel after the executor
> is shutdown then it should return false, the onComplete operation won't
> be called. We'll try to make the javadoc a bit clearer on this point.
>
> -Alan
>
>
>
More information about the loom-dev
mailing list