CompletableFuture updates and CompletionStage

Doug Lea dl at cs.oswego.edu
Thu Jul 11 10:29:07 UTC 2013


Last fall, when putting together class CompletableFuture, and when
many issues surrounding lambdas and Streams were still up in the air,
we postponed dealing with the question of how to extract out an
interface that would support usages by those who need the fluent
completion-style capabilities, but under different policies or
mechanisms that cannot otherwise be captured using a single class. The
lack of an interface was a serious problem because the variation among
policies and methods beyond the base fluent methods is so wide and
conflicting that some potential users wrote off CompletableFuture as
unusable -- some need method X, some cannot allow that same method X,
for X dealing with cancellation, blocking, overwrites, etc.

We finally last week settled this in an acceptable and simple way,
introducing interface CompletionStage, that is nearly just a subset of
existing CompletableFuture methods, and adjusting CompletableFuture
accordingly, in a way that provides a recipe for creating
interoperable CompletionStage implementations that may differ wrt
those methods not in the CompletionStage interface.  The adjustments
are small but still officially require CCC approval. We had to
introduce a method form ("whenComplete") to deal with exceptional
completions that otherwise required use of CompletableFuture-dependent
methods. Plus a couple of utilities and some spec rewordings, and an
overhaul of CompletableFuture class-level documentation to now
reference CompletionStage.

After expert-group and concurrency-interest discussions, no one
disagrees that this is an improvement. Some people have lingering
disagreements about those policy issues, but are more content that
there is now a straightforward way of obtaining the ones they want.

The updates have also been in lambda repo (although probably not used
much) for about a week.

Paul Sandoz has volunteered to coordinate the CCC and webrev
and will post the details. (Thanks Paul for adding this
to your already overcomitted workload!)

-Doug





More information about the core-libs-dev mailing list