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

Ron Pressler ron.pressler at oracle.com
Fri Nov 19 09:30:07 UTC 2021


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