[infinispan-dev] Async Notification API
Elias Ross
genman at noderunner.net
Fri May 15 20:10:09 EDT 2009
On Fri, May 15, 2009 at 5:00 PM, Elias Ross <genman at noderunner.net> wrote:
>
> Cache cache;
I noticed there's a type T you need to declare. I'm guessing you could do this:
CompletionService<ReturnType> c = cache.getCompletionService(ReturnType.class);
Now I think the "getter" might be better if it was more strongly typed:
AsyncCache<ReturnType> c = cache.getAsyncCache(ReturnType.class);
public interface AsyncCache<T> extends CompletionService<T> {
... other methods go there.
}
Still don't know if a type parameter is a Good Thing, since Cache
doesn't have one.
> You'd probably need to have every call to "getCompletionService"
> return a new instance. This is so multiple users don't see completed
> tasks.
I meant, of course, so multiple users don't see other users' completed
futures. Isolation is good.
> If you want a notification handler, simply tell users to create a
> thread that polls on operations completed.
This would look like:
final compSvc;
new Thread() {
public void run() {
while (true) { compSvc.poll(); }
}
}.start();
I guess the tricky part here is handling shutdown. Maybe having a way
to register for notification would make for better design in this
case.
More information about the infinispan-dev
mailing list