Well, this could be useful in many contexts, even outside of infinispan.  <br><br>One thing to consider is the three ways things finish in Futures: completion, cancellation, and exception.  I suspect the listener interface may want to handle all three, or some object that encapsulates those states.<br>
<br>I kindof like this flow in that case:<br><br>
        Future f = cache.putAsync(k, v).andInform(listener);<br><br>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>&gt;</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.  E.g.,<br>
<br>
        Future f = cache.putAsync(k, v);<br>
        f.get();<br>
<br>
But what if I don&#39;t want to wait on f.get(), I&#39;d rather be told when the future is done so I can do an f.get()?<br>
<br>
Sounds pretty useful to me.  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.  You register a cache listener, annotate a method with @RpcCallMade, receive an RpcCallMadeEvent.  But this is probably pretty useless, since you couldn&#39;t associate the notification with the specific put you&#39;ve just done.  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 &gt; 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.  NotifyingFuture.<br>
<br>
public interface NotifyingFuture extends Future {<br>
  void addListener(NotifyingFutureListener l);<br>
}<br>
<br>
public interface NotifyingFutureListener {<br>
  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>