我应该使用 akka.http.scaladsl.util.FastFuture 而不是 scala.concurrent.Future 吗?
评论说:
/**
* Provides alternative implementations of the basic transformation operations defined on [[scala.concurrent.Future]],
* which try to avoid scheduling to an [[scala.concurrent.ExecutionContext]] if possible, i.e. if the given future
* value is already present.
*/
我是否能获得任何性能提升,尤其是当我需要使用时Future.apply
, Future.successful
or Future.failed
?
这两种实现方式到底有什么区别?
本质上FastFuture
允许绕过Future
提交给ExecutionContext
如果未来已经完成(无论成功与否)。
简而言之,是的,它可以提高性能。这些是否可以忽略不计或很大,这取决于您正在开发的应用程序。
我相信有计划将这些改进纳入 Scala 2.12,但我从未听说过这些改进具体化了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)