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

查看:37
本文介绍了我应该使用 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.
 */

我是否有任何性能改进,尤其是当我需要使用Future.applyFuture.successfulFuture.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天全站免登陆