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:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(This would also let people write expression lambdas instead of block lambdas in some cases.)
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.