Euhm, what I meant to say is that it's more work to adapt a sync API into an async one, than the other way 'round, not impossible ;-)
On 06 Feb 2009, at 13:29, Geert Bevin wrote: > Hi, > > While working on the new cluster events implementation of these > methods of DsoCluster: > > Set<DsoNode> getNodesWithObject(Object object) > Map<?, Set<DsoNode>> getNodesWithObjects(Collection<?> objects) > <K> Set<K> getKeysForOrphanedValues(Map<K, ?> map) > > I'm obviously going through our whole channel, messages, stages SEDA > infrastructure to communicate with the L2 and get the response back to > the L1. I'm currently working on blocking these methods until the > response from the server comes back. > > This leads me to think that it might be maybe more useful to redesign > the API to be asynchronous with callbacks instead of blocking the > executing threads. It's always possible for users to adapt async to > sync, but not the other way around. I can definitely imagine > situations where it's more important to free the executing thread > immediately than to have the convenience of having a blocking response > as a method return. > > The methods would then become: > > void getNodesWithObject(Object object, NodesWithObjectsResult > callback) > void getNodesWithObjects(Collection<?> objects, NodesWithObjectsResult > callback) > void getKeysForOrphanedValues(Map<K, ?> map, OrphanedKeysResult > callback) > > With the callback interfaces something like: > > public interface NodesWithObjectsResult { > void gotResults(Map<?, Set<DsoNode>> results); > } > > public interface OrphanedKeysResult<K> { > void getResults(Set<K> results); > } > > The methods could then be used like this: > > cluster.getNodesWithObject(foo, new OrphanedKeysResult() { > public void gotResults(Map<?, Set<DsoNode>> results) { > // do stuff with results > } > }); > > Note that I just quickly typed these in the email, so there might be > typos/errors in the code. > > What do you think? > > Geert > > -- > Geert Bevin > Terracotta - http://www.terracotta.org > Uwyn "Use what you need" - http://uwyn.com > RIFE Java application framework - http://rifers.org > Flytecase Band - http://flytecase.be > Music and words - http://gbevin.com > > _______________________________________________ > tc-dev mailing list > tc-dev@lists.terracotta.org > http://lists.terracotta.org/mailman/listinfo/tc-dev -- Geert Bevin Terracotta - http://www.terracotta.org Uwyn "Use what you need" - http://uwyn.com RIFE Java application framework - http://rifers.org Flytecase Band - http://flytecase.be Music and words - http://gbevin.com _______________________________________________ tc-dev mailing list tc-dev@lists.terracotta.org http://lists.terracotta.org/mailman/listinfo/tc-dev