CompletionStage

Doug Lea dl at cs.oswego.edu
Mon Jul 1 09:31:21 PDT 2013


On 07/01/13 12:16, Sam Pullara wrote:
>
> On Jul 1, 2013, at 5:45 AM, Doug Lea <dl at cs.oswego.edu> wrote:
>>
>> I think that variable "future" is not bound to the stage you have in mind?
>> (The joys of fluency...)
>>
>> Try it with:
>>         ...
>>         CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
>>                 sleep(1000);
>>                 return "Doomed value";
>>             });
>>         future.cancel(true);
>>         future.exceptionally(...
>>
>>         // or, as of now, you could do instead
>>         future.onExceptionalCompletion(t -> {
>
> Makes some sense except for cancellation. I want that cancel() propagated through all the related futures in order to implement polling myself without threading the cancellation indicator through every layer.
>

Automatically cancelling the "other" in thenCombine and related
methods would not be universally popular, but we now have a
good answer for this! Feel free to create your own CompletionStage
implementation that does so. Sound good?

In other news, I think that with the multi-use onCompletion,
plus allowing all three (plain, async, custom) of handle,
we need to get rid of the problematic "exceptionally"
method. A few people will be unhappy, but better than
living with complaints about its javac-won't-let-me-rethrow
problems for years.

-Doug



More information about the lambda-libs-spec-observers mailing list