Re: CompletableFuture dependent ordering

Benjamin Manes via Concurrency-interest <[email protected]> Tue, 5 Jan 2021 04:04:55 -0800
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <CAGu0=MO3TV6U02jMH5hKU57N=Zk-5Oc1QnEFKDunM59rtB_RFw@mail.gmail.com>
Thank you.  I recall some of those early issues so that makes sense. I
agree no ordering should be relied upon but lacked a good explanation for
the implementation preference.

On Tue, Jan 5, 2021 at 3:59 AM Doug Lea via Concurrency-interest <
[email protected]> wrote:

> On 1/4/21 5:28 PM, Benjamin Manes via Concurrency-interest wrote:
> >
> > CompletableFuture maintains a Treiber stack for processing dependents,
> > such as "thenAccept" and "whenComplete" actions. I couldn't find a
> > previous discussion on this design decision. Can you please educate me
> > on why a LIFO stack was preferred over a FIFO queue?
>
> There was some implicit discussion of this when people discovered that
> the initial trial versions tended to blow call stacks and retain
> unneeded heap pointers in recursive usages. As others have noted,
> there's no guarantee about triggering order, so choosing one that tends
> to use fewer resources (in the trampoline-like postComplete() method)
> seems to be the best option. In some applications, the triggering order
> can be surprising, but his would be true no matter what choice was made.
>
>
> _______________________________________________
> Concurrency-interest mailing list
> [email protected]
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>

_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest