question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Futures.whenAllComplete(...).run()

See original GitHub issue

~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.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
cpovirkcommented, Nov 6, 2017

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

0reactions
cpovirkcommented, Aug 10, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Futures (Guava: Google Core Libraries for Java 20.0 API)
Registers separate success and failure callbacks to be run when the Future 's computation is complete or, if the computation is already complete,...
Read more >
Guava's Futures and ListenableFuture - Baeldung
Future is the ability to add listeners to run on completion, which is a common feature provided ... whenAllComplete() methods, respectively.
Read more >
com.google.common.util.concurrent.Futures.whenAllComplete ...
Creates a FutureCombiner that processes the completed futures whether or not they're successful. Popular methods of Futures. addCallback. Registers separate ...
Read more >
Futures.FutureCombiner (Guava - javadoc.io
whenAllComplete (com.google.common.util.concurrent. ... result of calling Callable.call() in combiner when all futures complete, using the specified executor ...
Read more >
Get individual completion of combined Futures - Stack Overflow
addCallback( Futures.whenAllComplete(futureA, futureB).call( () -> { // Some computation with results of both futures }, executor), ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found