Guava: Futures.whenAllComplete(...).run()

Created on 26 Jan 2016  路  5Comments  路  Source: google/guava

~6% of callers of our old Futures.combine either pass a Callable<Void>, ignore the result of combine, or both. Some of these might need to use Callable because they throw checked exceptions, but others would probably prefer not to write the extra boilerplate (mostly return null but also <Void>).

We could help them out by providing run(Runnable) alongside call(Callable). We could still return ListenableFuture<?> for users who need to check for errors or await the result.

6% is a small percentage, but the API is also very low cost (easy to understand and "hidden" in the FutureCombiner type). It would also match the overloads of ExecutorService.submit.

P3 package=concurrent status=research type=addition

Most helpful comment

(This would also let people write expression lambdas instead of block lambdas in some cases.)

All 5 comments

Hi,
I've made certain code changes regarding that issue and was wondering if it's still being evaluated by the guava team.

We may well add it someday. It's just a matter of our finding the time to run it through our internal API-review process.

I'm not quite familiar with the process yet, but perhaps I can contribute the changes to the project?

Unfortunately it's an internal-only process. But this addition should be straightforward enough, so I'll try to take care of it when I have a spare moment.

(This would also let people write expression lambdas instead of block lambdas in some cases.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bocete picture Bocete  路  3Comments

oliviercailloux picture oliviercailloux  路  4Comments

PhilippWendler picture PhilippWendler  路  4Comments

gissuebot picture gissuebot  路  5Comments

ernestp picture ernestp  路  3Comments