<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 16 May 2009, at 00:47, Adrian Cole wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Well, this could be useful in many contexts, even outside of infinispan.&nbsp; <br><br>One thing to consider is the three ways things finish in Futures: completion, cancellation, and exception.&nbsp; I suspect the listener interface may want to handle all three, or some object that encapsulates those states.</blockquote><div><br></div><div>Well, the listener just notifies that a future is done, passing back a reference to the same future. &nbsp;Any sane implementation of the listener would then call future.get() to test for exceptions, or test&nbsp;future.isCancelled() if it cares.</div><br><blockquote type="cite">I kindof like this flow in that case:<br><br> &nbsp; &nbsp; &nbsp;&nbsp; Future f = cache.putAsync(k, v).andInform(listener);</blockquote><div><br></div><div>+1 to a builder-like API.</div><br><blockquote type="cite">where NotifyingFuture has a method:<br><br><div style="margin-left: 40px;">NotifyingFuture andInform(NotifyingFutureListener listener)<br><br></div>interesting stuff...<br> what do you think?<br><br>-Adrian<br>jclouds<br><br><div class="gmail_quote">On Sat, May 16, 2009 at 1:27 AM, Manik Surtani <span dir="ltr">&lt;<a href="mailto:manik@jboss.org">manik@jboss.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> While the new async API has been getting rave reviews, someone did bring up async notifications. &nbsp;E.g.,<br> <br> &nbsp; &nbsp; &nbsp; &nbsp;Future f = cache.putAsync(k, v);<br> &nbsp; &nbsp; &nbsp; &nbsp;f.get();<br> <br> But what if I don't want to wait on f.get(), I'd rather be told when the future is done so I can do an f.get()?<br> <br> Sounds pretty useful to me. &nbsp;But just wanted to sound you guys on the API choices for notifications.<br> <br> My immediate thought was to use the existing notification API. &nbsp;You register a cache listener, annotate a method with @RpcCallMade, receive an RpcCallMadeEvent. &nbsp;But this is probably pretty useless, since you couldn't associate the notification with the specific put you've just done. &nbsp;Even if you have the key in the event (which is unlikely - since we need to use the same event for all cache operations, some which take > 1 key such as putAll()), multiple threads could be working on the same key.<br> <br> Another approach is to design a sub-interface to Future. &nbsp;NotifyingFuture.<br> <br> public interface NotifyingFuture extends Future {<br> &nbsp;void addListener(NotifyingFutureListener l);<br> }<br> <br> public interface NotifyingFutureListener {<br> &nbsp;void futureDone(Future f);<br> }<br> <br> WDYT?<br> --<br> Manik Surtani<br> <a href="mailto:manik@jboss.org" target="_blank">manik@jboss.org</a><br> Lead, Infinispan<br> Lead, JBoss Cache<br> <a href="http://www.infinispan.org" target="_blank">http://www.infinispan.org</a><br> <a href="http://www.jbosscache.org" target="_blank">http://www.jbosscache.org</a><br> <br> <br> <br> <br> _______________________________________________<br> infinispan-dev mailing list<br> <a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a><br> <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br> </blockquote></div><br></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--</div><div>Manik Surtani</div><div><a href="mailto:manik@jboss.org">manik@jboss.org</a></div><div>Lead, Infinispan</div><div>Lead, JBoss Cache</div><div><a href="http://www.infinispan.org">http://www.infinispan.org</a></div><div><a href="http://www.jbosscache.org">http://www.jbosscache.org</a></div><div><br></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"> </div><br></body></html>