<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Romain,</div><div class=""><br class=""></div><div class="">Intersting proposal. As I felt reading you that we misse the CompletableFuture stuff in Java 8, I just repeat here that the agreed on fireAsync signatures </div><div class=""><br class=""></div><div class=""><U extends T> CompletionStage<U> fireAsync(U event);</div><div class="">and</div><div class=""><U extends T> CompletionStage<U> fireAsync(U event, Executor executor);<br class=""><br class="">Yeah it’s CompletionStage because Jozef preferred using interfaces in our API, but I guess implementation will use CompletableFuture under the hood to avoid reinventing the wheel.</div><div class=""><br class=""></div><div class="">With this approach your example:</div><div class=""><br class=""></div><div class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div text="#000000" bgcolor="#FFFFFF" class=""><div dir="ltr" class=""><div class="">event.fireAsync(new LetTheWorldKnow()).thenRun(() -> System.out.println("We did it!"));</div></div></div></blockquote></div></div><div class=""><br class=""></div><div class="">will work without adding constraint on observer signature.</div><div class=""><br class=""></div><div class="">Regarding the observer part, we already discuss similar approach. In a former version of my async event doc I proposed using return type on observer to do discrimination between async and sync and Mark made a suggestion near yours during this meeting:</div><div class=""><br class=""></div><div class=""><a href="http://transcripts.jboss.org/meeting/irc.freenode.org/cdi-dev/2015/cdi-dev.2015-02-25-17.06.log.html" class="">http://transcripts.jboss.org/meeting/irc.freenode.org/cdi-dev/2015/cdi-dev.2015-02-25-17.06.log.html</a></div><div class=""><br class=""></div><div class="">(search for the first “signature” in text)</div><div class=""><br class=""></div><div class="">The main drawback of this approach is to let end user generate the returned CompletableFuture. So each async observer should provide a way to construct this completableFuture. The second question is the type param of the returned CompletableFuture. Should we use raw type? Now we could imagine helped to do that but...</div><div class=""><br class=""></div><div class="">Don’t get me wrong, I’d love to find a solution based on this kind of idea, but I fear it will add more complexity than double activation.</div><div class=""><br class=""></div><div class="">Antoine</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">Le 1 avr. 2015 à 09:15, Romain Manni-Bucau <<a href="mailto:rmannibucau@gmail.com" class="">rmannibucau@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><p dir="ltr" class="">No, fireAsync is still needed for all the reason we mzntionned - strongest one being the fact we need a return type and cant change fire - but using the return type we have the double activation without introducing a new API. Said otherwise API stays natural on both sides which was my main fear with a fireAsync and an @ObservesAsync (or any other new api we talked about). And we have the bonus to be aligned on SE async which sounds quite interesting for the future.</p>
<div class="gmail_quote">Le 1 avr. 2015 08:48, "Jozef Hartinger" <<a href="mailto:jharting@redhat.com" class="">jharting@redhat.com</a>> a écrit :<br type="attribution" class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF" class="">
So instead of calling observers asynchronously you suggest turning
observers into producers of CompletableFuture that will then be
completed asynchronously?<br class="">
<br class="">
<div class="">On 03/31/2015 06:21 PM, Romain
Manni-Bucau wrote:<br class="">
</div>
<blockquote type="cite" class="">
<div dir="ltr" class="">// fire side
<div class="">event.fireAsync(new LetTheWorldKnow()).thenRun(() ->
System.out.println("We did it!"));</div>
<div class=""><br class="">
</div>
<div class="">// observer side</div>
<div class="">CompletableFuture iWantToKnow(@Observes LetTheWorldKnow
event) {}</div>
<div class=""><br class="">
</div>
<div class="">// impl behavior would be like
CompletableFuture.allOf(allObserverReturnedInstances) to be
aligned on CompletableFuture behavior I think</div>
<div class=""><br class="">
</div>
<div class="">Am I clearer?</div>
<div class=""><br class="">
</div>
</div>
<div class="gmail_extra"><br clear="all" class="">
<div class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class=""><br class="">
<span style="font-size:small" class="">Romain
Manni-Bucau</span><br class="">
<a href="https://twitter.com/rmannibucau" target="_blank" class="">@rmannibucau</a> | <a href="http://rmannibucau.wordpress.com/" target="_blank" class="">Blog</a> | <a href="https://github.com/rmannibucau" target="_blank" class="">Github</a> | <a href="https://www.linkedin.com/in/rmannibucau" target="_blank" class="">LinkedIn</a> | <a href="http://www.tomitribe.com/" target="_blank" class="">Tomitriber</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br class="">
<div class="gmail_quote">2015-03-31 18:15 GMT+02:00 Sven
Linstaedt <span dir="ltr" class=""><<a href="mailto:sven.linstaedt@gmail.com" target="_blank" class="">sven.linstaedt@gmail.com</a>></span>:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="">
<div class="">Hi Romain,</div>
<div class=""><br class="">
</div>
I am not sure, I have fully understand how an observer
with <span style="font-size:12.8000001907349px" class="">CompletableFuture could
look like. Could you give us an example? </span>
<div class=""><span style="font-size:12.8000001907349px" class=""><br class="">
</span></div>
<div class=""><span style="font-size:12.8000001907349px" class="">Afair </span><span style="font-size:12.8000001907349px" class="">CompletableFuture</span><span style="font-size:12.8000001907349px" class=""> was considered
to be used in the "trigger" side in order to track
async event invocation completion.</span></div>
<div class=""><span style="font-size:12.8000001907349px" class=""><br class="">
</span></div>
<div class=""><span style="font-size:12.8000001907349px" class="">br, Sven</span></div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">
<div class="">
<div class="">2015-03-31 18:00 GMT+02:00 Romain
Manni-Bucau <span dir="ltr" class=""><<a href="mailto:rmannibucau@gmail.com" target="_blank" class="">rmannibucau@gmail.com</a>></span>:<br class="">
</div>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">
<div class="">
<div dir="ltr" class="">Hi guys,
<div class=""><br class="">
</div>
<div class="">on async topic if I followed we are at the
point where we are looking for an activation
on the observer side.</div>
<div class=""><br class="">
</div>
<div class="">Since Java 8 has now CompletableFuture it
would be great to use it. Today the spec
doesnt use observer returned values so it is
mainly a bad practise to have one even if not
strictly forbidden - BTW never saw it in real
applications - plus spec is not compatible -
not specified at all - with CompletableFuture
since it is a new API so we can use it as a
marker.</div>
<div class=""><br class="">
</div>
<div class="">This is quite interesting for few reasons:</div>
<div class="">1- we have our double activation</div>
<div class="">2- API is user friendly (observer is async
and has an async signature)</div>
<div class="">3- open door for future async enhancements
(hopefully not in CDI) with composition of
these observers</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Only point I'm not sure is should these
observers support sync events. I don't see
anything blocking to do it but can have missed
something.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">wdyt?</div>
<span class=""><font color="#888888" class="">
<div class=""><br clear="all" class="">
<div class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class=""><br class="">
<span style="font-size:small" class="">Romain
Manni-Bucau</span><br class="">
<a href="https://twitter.com/rmannibucau" target="_blank" class="">@rmannibucau</a>
| <a href="http://rmannibucau.wordpress.com/" target="_blank" class="">Blog</a> | <a href="https://github.com/rmannibucau" target="_blank" class="">Github</a> | <a href="https://www.linkedin.com/in/rmannibucau" target="_blank" class="">LinkedIn</a> |
<a href="http://www.tomitribe.com/" target="_blank" class="">Tomitriber</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</font></span></div>
<br class="">
</div>
</div>
_______________________________________________<br class="">
cdi-dev mailing list<br class="">
<a href="mailto:cdi-dev@lists.jboss.org" target="_blank" class="">cdi-dev@lists.jboss.org</a><br class="">
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank" class="">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br class="">
<br class="">
Note that for all code provided on this list, the
provider licenses the code under the Apache License,
Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank" class="">http://www.apache.org/licenses/LICENSE-2.0.html</a>).
For all other ideas provided on this list, the
provider waives all patent and other intellectual
property rights inherent in such information.<br class="">
</blockquote>
</div>
<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
<br class="">
<fieldset class=""></fieldset>
<br class="">
<pre class="">_______________________________________________
cdi-dev mailing list
<a href="mailto:cdi-dev@lists.jboss.org" target="_blank" class="">cdi-dev@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank" class="">https://lists.jboss.org/mailman/listinfo/cdi-dev</a>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank" class="">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.</pre>
</blockquote>
<br class="">
</div>
</blockquote></div>
_______________________________________________<br class="">cdi-dev mailing list<br class=""><a href="mailto:cdi-dev@lists.jboss.org" class="">cdi-dev@lists.jboss.org</a><br class="">https://lists.jboss.org/mailman/listinfo/cdi-dev<br class=""><br class="">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.</div></blockquote></div><br class=""></body></html>