Look at the usage of CompletionService in shindig to see how this is useful.
Sure you *could* wrap every API call in a Callable, however that would lead to extra thread consumption. Another benefit of a Future<..> api is that you can execute a small amount of code on the request thread to set up your Future. This allows for ThreadLocal use on the servlet thread, request scoped guice injection, and more. I agree that it's a bit ugly, and you can get if you need to take the output of a Future and pass it to the input of another it gets confusing (even with Futures.transform(...) from guava) On Wednesday, October 10, 2012, Jan Willem Janssen wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 10/10/12 10:03 AM, Ian Boston wrote: > > I will have a go since I was involved in the early SPI. > > > > Many of the calls in a real Social network impl are remote or over > > links that may have IO waits. If you use Futures you can dispatch > > them at the start of the request and collect them all at the end of > > the request hence interleaving IO time more effectively. Obviously > > that assumes you SPI impl is capable of being event driven. > > Wouldn't the interleaving be an issue of the caller (ie: Shindig) > instead of the SPI? I mean: you can wrap the calls to your SPI in > Futures when its desired to have interleaving. Wouldn't this give the > same semantics? > > > - -- > Met vriendelijke groeten | Kind regards > > Jan Willem Janssen | Software Architect > +31 631 765 814 > > /My world is:/ > > Luminis Technologies B.V. > IJsselburcht 3 > 6825 BS Arnhem > +31 88 586 46 30 > > http://www.luminis-technologies.com > http://www.luminis.eu > > KvK (CoC) 09 16 28 93 > BTW (VAT) NL8169.78.566.B.01 > -----BEGIN PGP SIGNATURE----- > Version: GnuPG/MacGPG2 v2.0.17 (Darwin) > Comment: GPGTools - http://gpgtools.org > Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ > > iQIcBAEBAgAGBQJQdTAfAAoJEKF/mP2eHDc4YsYQAKIqrHbXvPNmYw6Ctt0RWOey > I4gyI/eAiNVEjwoFLSLUzLm77pBFtikuRttPugf93w5HFWVu1Dr31WKD2NHkejQx > JsdHaAx3XA9hSKfcqgOGgXKFKdqNdK25B1tz0v76Dc3IVa+EX85+W8CpzXYrYJVQ > sEhvFfT8eMtkSctMNxmmmKnXllOEyrLYCSpWJ/6F8wpw6VUXrzaV5UfmfBxksU60 > 1cfvnFdT0Pu1WFQHFcyHhCqyelHNLyA6bIrz936ZMjhoWwasPLc2wRZd6bmIOm30 > 6BCtuRKeYHWBGc5jKo6GPlvVYwrgrL/CyqbOCAWTRIPxolzhEyRTFsY31UBkEgFE > +qVei/Gh2UZBML82TnqOeDX9pZE0mXRVdlH9G8CgIH/zHPJltGmqDe4LBcGMddfP > TeR44dvOtQ5cNRJImr8UJhLhPYyUxZBj4H61aikE6fNHKCpEWrWC4DGQ+7LYiW54 > hgXI2Xt2xJj1/PxeOpM1j8o0cVYGE1nR9mJbUE/USN8ZoYskmssFx/ucy2o6aK6I > 5ngKJkKVrzMXJYAO3GEdcPLzSdqXfh7be/tGMKD71sbYqcPaEaGQZyD61T/5JRLd > HC3C183Eo7oBudh7qoOUAZ09v8O9Ye1D7BvugmmNQACTLYRZZlgfHOW3tBEfMoZx > 3oknrE5iwkMFwJAWam2f > =utq4 > -----END PGP SIGNATURE----- > > -- Paul Lindner -- lind...@inuus.com -- profiles.google.com/pmlindner