在文档中不清楚Fastkka在akka中的用途是什么:
Provides alternative implementations of the basic transformation operations defined on Future, which try to avoid scheduling to an ExecutionContext if possible, i.e. if the given future value is already present.
How is it different from Future, Can someone explain with an example in what cases this to be used and what benefit does it provide in terms of performance or any other aspects?
当ExecutionContext在map呼叫中使用an时,这会在scala中增加额外的调度成本Future,而使用akka时,FastFuture它可以在同一线程中执行映射,从而避免了潜在的上下文切换,并可能导致非常短的任务(例如简单的数字处理)丢失缓存。因此对于快速的map操作FastFuture应该更快。
请注意,flatMap通常也需要ExecutionContextin,FastFuture因为它应该使用in 来调度生成的Futures。
可能值得检查Viktor Klang的博客以及Scala贡献者页面上与Futures相关的讨论。