[infinispan-dev] Async Notification API
Manik Surtani
manik at jboss.org
Fri May 15 20:22:45 EDT 2009
On 16 May 2009, at 01:00, Elias Ross wrote:
> On Fri, May 15, 2009 at 4:27 PM, Manik Surtani <manik at jboss.org>
> wrote:
>
>> While the new async API has been getting rave reviews, someone did
>> bring up
>> async notifications. E.g.,
>>
>> Future f = cache.putAsync(k, v);
>> f.get();
>>
>> 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()?
>
> Kind of hard to understand the use case here. There's Future.isDone()
> and a Future.get() with timeout.
>
> I think the biggest problem I see with the Async design is you're not
> sure which order multiple operations will complete in. For instance,
> if you are doing two puts you don't necessary know which order they
> might complete in, but you want to know when they might complete.
More than complete, I take it your concern is the order in which they
are executed? E.g.,
cache.putAsync(k, v1);
cache.putAsync(k, v2);
and you are not guaranteed that the 2nd put will overwrite the 1st
one? If so, that is a valid concern, but one that should be dealt
with internally.
And since execution order is more important than completion order, I'm
not sure of the value of CompletionService. For example, the first
put may be executed first on the local cache, but may take longer to
complete, for example, if v1 is slower to marshal when doing RPC, than
v2)
--
Manik Surtani
manik at jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org
More information about the infinispan-dev
mailing list