[External] : Re: A new build and a new structured concurrency API

Alex Otenko oleksandr.otenko at gmail.com
Fri Nov 19 13:12:34 UTC 2021


Thanks. Can this be taken literally to mean that a task could shutdown() in
finally to achieve exactly the same effect, and that won't cancel its own
Future? (I.e. that if called from inside a task, there is a notion of "me",
and "cancel all except me" is doable)

Alex

On Fri, 19 Nov 2021, 09:30 Ron Pressler, <ron.pressler at oracle.com> wrote:

> You *can* use a finally clause instead of onComplete. It’s even more
> general. The purpose of the completion handler parameter is to perform the
> role you say in a way that’s nicely factored out into a “policy object.”
> It’s a convenience mechanism, not an essential one.
>
> — Ron
>
> > On 19 Nov 2021, at 09:00, Alex Otenko <oleksandr.otenko at gmail.com>
> wrote:
> >
> > 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
>
>


More information about the loom-dev mailing list