I have references to n Future instances f1,.....fn
. Is it possible to use Future.apply
to create a Future that would complete only when at least one of the n Futures completes, without constantly checking their completion status, but instead by some more efficient way, maybe a callback?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Future.firstCompletedOf(Seq(f1, ..., fn))
Asynchronously and non-blockingly returns a new Future to the result of the first future in the list that is completed.