[cdi-dev] async: back to completion future?

Reza Rahman reza_rahman at lycos.com
Mon Mar 7 08:01:53 EST 2016


I think in this case it is worth exploring to see if there is another way of accomplishing this goal. This is an issue generally for Java EE, not CDI alone. I don't think we can afford to avoid the CompletableFuture API for this reason. Simply too many people will expect that API.

> On Mar 7, 2016, at 2:3AM, Martin Kouba <mkouba at redhat.com> wrote:
> 
> Dne 6.3.2016 v 15:39 Romain Manni-Bucau napsal(a):
>> Hi guys,
>> 
>> as a user having a ComlpetionStage makes me loose some JDK utilities,
>> can we move back to CompletionFuture?
>> 
>> It would allow for instance:
>> 
>> // doesn't work with CompletionStage
>> CompletionFuture.allOf(event1.fireAsync(...), event2.fireAsync(...))
>>       .then(...)
> 
> Well, this should work if the underlying CompletionStage impl supports 
> toCompletableFuture(), i.e. in Weld 3:
> 
> CompletableFuture.allOf(event1.fireAsync(...).toCompletableFuture(), 
> event2.fireAsync(...).toCompletableFuture())
> 
> AFAIK the default async execution facility of CompletableFuture is 
> ForkJoinPool.commonPool() which is not a good fit for Java EE. Using the 
> CompletionStage interface allows us to wrap the async calls without the 
> specified executor (e.g. CompletionStage.thenApplyAsync(Function<? super 
> T, ? extends U>)) and supply a default one provided by the impl.
> 
> 
>> 
>> Romain Manni-Bucau
>> @rmannibucau <https://twitter.com/rmannibucau> | Blog
>> <http://rmannibucau.wordpress.com> | Github
>> <https://github.com/rmannibucau> | LinkedIn
>> <https://www.linkedin.com/in/rmannibucau> | Tomitriber
>> <http://www.tomitribe.com>
>> 
>> 
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>> 
>> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
> 
> -- 
> Martin Kouba
> Software Engineer
> Red Hat, Czech Republic
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
> 
> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.



More information about the cdi-dev mailing list