我应该使用akka.http.scaladsl.util.FastFuture而不是scala.concurrent.Future吗? [英] Should I use akka.http.scaladsl.util.FastFuture instead of scala.concurrent.Future?

查看:60
本文介绍了我应该使用akka.http.scaladsl.util.FastFuture而不是scala.concurrent.Future吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该使用akka.http.scaladsl.util.FastFuture而不是scala.concurrent.Future吗?

Should I use akka.http.scaladsl.util.FastFuture instead of 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.
 */

我是否获得了任何性能改进,特别是当我需要使用$ b $时b Future.apply Future.successful Future.failed

Do I get any performance improvement especially when I need to use Future.apply, Future.successful or Future.failed?

这两个实现之间到底有什么区别?

What exactly is the difference between the two implementations?

推荐答案

基本上, FastFuture 允许将 Future 的提交绕过到 ExecutionContext 如果将来已经完成(无论成功与否)。

Essentially FastFuture allows to bypass the Future's submission to an ExecutionContext in case the future is already completed (either successfully or not).

总之,是的,它可以为您带来性能改进。这些是微不足道的还是实质性的,取决于您正在开发的应用程序。

So in short, yes, it can give you performance improvements. Whether those will be negligible or substantial, it depends on the application you are developing.

我相信有计划将这些改进作为Scala 2.12的一部分,但我从来没有听说那些被人具体化了。

I believe there was a plan to make these improvements part of Scala 2.12, but I never heard of those being concretised.

这篇关于我应该使用akka.http.scaladsl.util.FastFuture而不是scala.concurrent.Future吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆