[External] : Re: A new build and a new structured concurrency API
Pedro Lamarão
pedro.lamarao at prodist.com.br
Thu Nov 18 17:15:33 UTC 2021
When I think about a "fork/join" type of problem,
I get unsure about what "task abandonment notification" could look like,
since you cannot know in advance how many tasks you would have forked in
the next partitioning.
Pedro.
Em qui., 18 de nov. de 2021 às 13:45, Alex Otenko <
oleksandr.otenko at gmail.com> escreveu:
> 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
>
> Alex
>
> On Thu, 18 Nov 2021, 11:31 Alan Bateman, <Alan.Bateman at oracle.com> wrote:
>
> > On 18/11/2021 10:02, Alex Otenko wrote:
> > > I see why break may be an analogue, but don't see why it is the right
> > one.
> > >
> > > Right now the tasks finish in one of four ways:
> > >
> > > Success with a value
> > > Failure with Exception
> > > Someone aborted, a subclass of Failure
> > > Shutdown
> > >
> > > And it is ok to use onComplete for three cases, but not the last? So
> now
> > > really all handling is spread across two sites, predictably requiring
> > more
> > > code and more complexity in interactions with the other three
> termination
> > > conditions.
> > A task completes with a result, an exception, or it is cancelled. This
> > will be familiar to everyone that uses Future::get. This project has not
> > introduced any new states or ways for a task to complete. When using the
> > 2-arg fork method then the onComplete operation is invoked when the task
> > completes, irrespective of whether it completed with a result,
> > exception, or was cancelled.
> >
> > The shutdown method is on StructuredExecutor, not Future. The javadoc
> > tries to be clear that it is for cases where you've got an interesting
> > result and are no longer interested in the results of other tasks. The
> > shutdown method closes the front door to prevent new threads from
> > starting. It also interrupts the threads that are running the tasks that
> > haven't completed yet. It also tries to make it clear that when shutdown
> > completes that are tasks are "done" (it links to Future::isDone). You
> > shouldn't need to use Future::get with this API but if you were then you
> > should see that Future::get wakes up when SE::shutdown is called.
> >
> > -Alan
> >
> >
> >
> >
> >
>
--
Pedro Lamarão
https://www.prodist.com.br
Securing Critical Systems
Tel: +55 11 4380-6585
Antes de imprimir esta mensagem e seus anexos, certifique-se que seja
realmente necessário.
Proteger o meio ambiente é nosso dever.
Before printing this e-mail or attachments, be sure it is necessary.
It is in our hands to protect the environment.
More information about the loom-dev
mailing list