<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-03-07 11:17 GMT+01:00 Martin Kouba <span dir="ltr">&lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;</span>:<br><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"><br>
<br>
Dne 7.3.2016 v 11:10 Romain Manni-Bucau napsal(a):<br>
<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"><span class="">
<br>
2016-03-07 10:57 GMT+01:00 Martin Kouba &lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a><br></span><span class="">
&lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;&gt;:<br>
<br>
    Dne 7.3.2016 v 09:45 Romain Manni-Bucau napsal(a):<br>
<br>
        2016-03-07 9:07 GMT+01:00 Martin Kouba &lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a><br>
        &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;<br></span>
        &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a> &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;&gt;&gt;:<div><div class="h5"><br>
<br>
<br>
             Dne 7.3.2016 v 09:03 Romain Manni-Bucau napsal(a):<br>
<br>
<br>
                 Le 7 mars 2016 08:35, &quot;Martin Kouba&quot; &lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a><br>
        &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a> &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;&gt;<br>
                 &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a> &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;<br>
        &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a> &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;&gt;&gt;&gt; a écrit :<br>
<br>
                   &gt;<br>
                   &gt; Dne 6.3.2016 v 15:39 Romain Manni-Bucau napsal(a):<br>
                   &gt;<br>
                   &gt;&gt; Hi guys,<br>
                   &gt;&gt;<br>
                   &gt;&gt; as a user having a ComlpetionStage makes me loose<br>
        some JDK<br>
                 utilities,<br>
                   &gt;&gt; can we move back to CompletionFuture?<br>
                   &gt;&gt;<br>
                   &gt;&gt; It would allow for instance:<br>
                   &gt;&gt;<br>
                   &gt;&gt; // doesn&#39;t work with CompletionStage<br>
                   &gt;&gt; CompletionFuture.allOf(event1.fireAsync(...),<br>
                 event2.fireAsync(...))<br>
                   &gt;&gt;        .then(...)<br>
                   &gt;<br>
                   &gt;<br>
                   &gt; Well, this should work if the underlying<br>
        CompletionStage impl<br>
                 supports toCompletableFuture(), i.e. in Weld 3:<br>
                   &gt;<br>
<br>
                 Yes but it is not natural to convert it IMO = we can do<br>
        better<br>
<br>
                   &gt;<br>
<br>
        CompletableFuture.allOf(event1.fireAsync(...).toCompletableFuture(),<br>
                 event2.fireAsync(...).toCompletableFuture())<br>
                   &gt;<br>
                   &gt; AFAIK the default async execution facility of<br>
                 CompletableFuture is<br>
                 ForkJoinPool.commonPool() which is not a good fit for<br>
        Java EE.<br>
                 Using the<br>
                 CompletionStage interface allows us to wrap the async calls<br>
                 without the<br>
                 specified executor (e.g.<br>
                 CompletionStage.thenApplyAsync(Function&lt;? super<br>
                 T, ? extends U&gt;)) and supply a default one provided by<br>
        the impl.<br>
                   &gt;<br>
<br>
                 Should use the pool in which the evznt is fired then<br>
        &quot;then step&quot; is<br>
                 synchronous is my sample so all is decided at fire time<br>
<br>
<br>
             I don&#39;t talk about your particular example - I understand<br>
        that it&#39;s<br>
             not using async exec (although the &quot;then()&quot; method does not<br>
        exist).<br>
<br>
<br>
        was supposed to represent the different flavours (thenRun,<br>
        thenCompose,<br>
        ...) ;).<br>
<br>
        That said I agree on the state switching the pool is better but with<br>
        these 2 notes:<br>
<br>
        - could be better to hide these poorly designed methods then -&gt;<br>
        don&#39;t<br>
        use CompletionXXX but a CDI API with a bridge to CompletionX to<br>
        let the<br>
        user go back on SE tools<br>
<br>
<br>
    Yep, this is one of the possible solutions. On the other hand, I<br>
    don&#39;t think it&#39;s poorly designed. CompletionStage defines the<br>
    &quot;default asynchronous execution facility&quot; and CDI spec states that<br>
    the CompletionStage returned by fireAsync methods is<br>
    container-specific. The impl may choose to clarify this &quot;default<br>
    asynchronous execution facility&quot;, i.e. there&#39;s place for innovation...<br>
<br>
        - we still don&#39;t have a *standard* config for the pool(s)<br>
        underlying CDI<br>
        features so it sounds as poor as SE solution IMO (at least a<br>
        core/max/ttl config in beans.xml)<br>
<br>
<br>
    I don&#39;t think this should be standardized...<br>
<br>
<br>
Why? Typically if you take @Asynchronous (EJB spec) you have already<br>
this issue and this is often avoided when portability matters for that<br>
particular reason you don&#39;t know how you will behave. Or do you think<br>
concurrency-utilities solves it?<br>
</div></div></blockquote>
<br>
No, it doesn&#39;t. I think it should remain impl-specific. You know how it will behave - it will be async. And if needed you could tune up the config, depending on the container. If you specify core/max/ttl the container will not be able to optimize.<div class=""><div class="h5"><br></div></div></blockquote><div><br></div><div>&quot;it will be async&quot; &lt;- then container is free to have a single thread (would make a js impl possible :)) which would totally break you app which is supposed to be scalable. Also if the config is container dependent you can just not be able to configure it - I know the container would be bad but you don&#39;t always choose it. In any case not having a config means the feature is not reliable and depending on the container specific features means you are aside the EE goals of reliability in the time IMHO.</div><div><br></div><div>Also the container opitmizations can have side effects so if not behaving as expected it needs to be spec-ed.</div><div><br></div><div>Threading model is something central when it starts to be used for a bit mroe than fire and forget once a day, ignoring it is killing before the birth the API you can add on top of it IMO.</div><div> </div><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 class=""><div class="h5">
<br>
<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">
<br>
<br>
<br>
                   &gt;<br>
                   &gt;&gt;<br>
                   &gt;&gt; Romain Manni-Bucau<br>
                   &gt;&gt; @rmannibucau &lt;<a href="https://twitter.com/rmannibucau" rel="noreferrer" target="_blank">https://twitter.com/rmannibucau</a>&gt; | Blog<br>
                   &gt;&gt; &lt;<a href="http://rmannibucau.wordpress.com" rel="noreferrer" target="_blank">http://rmannibucau.wordpress.com</a>&gt; | Github<br>
                   &gt;&gt; &lt;<a href="https://github.com/rmannibucau" rel="noreferrer" target="_blank">https://github.com/rmannibucau</a>&gt; | LinkedIn<br>
                   &gt;&gt; &lt;<a href="https://www.linkedin.com/in/rmannibucau" rel="noreferrer" target="_blank">https://www.linkedin.com/in/rmannibucau</a>&gt; | Tomitriber<br>
                   &gt;&gt; &lt;<a href="http://www.tomitribe.com" rel="noreferrer" target="_blank">http://www.tomitribe.com</a>&gt;<br>
                   &gt;&gt;<br>
                   &gt;&gt;<br>
                   &gt;&gt;<br>
                   &gt;&gt; _______________________________________________<br>
                   &gt;&gt; cdi-dev mailing list<br>
                   &gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
        &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt; &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
        &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;&gt;<br>
                 &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
        &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt; &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
        &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;&gt;&gt;<br>
                   &gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
                   &gt;&gt;<br>
                   &gt;&gt; Note that for all code provided on this list, the<br>
        provider<br>
                 licenses<br>
                 the code under the Apache License, Version 2<br>
                 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For<br>
        all other<br>
                 ideas<br>
                 provided on this list, the provider waives all patent<br>
        and other<br>
                 intellectual property rights inherent in such information.<br>
                   &gt;&gt;<br>
                   &gt;<br>
                   &gt; --<br>
                   &gt; Martin Kouba<br>
                   &gt; Software Engineer<br>
                   &gt; Red Hat, Czech Republic<br>
<br>
<br>
             --<br>
             Martin Kouba<br>
             Software Engineer<br>
             Red Hat, Czech Republic<br>
<br>
<br>
<br>
    --<br>
    Martin Kouba<br>
    Software Engineer<br>
    Red Hat, Czech Republic<br>
<br>
<br>
</blockquote>
<br>
-- <br>
Martin Kouba<br>
Software Engineer<br>
Red Hat, Czech Republic<br>
</div></div></blockquote></div><br></div></div>