问题
Should I use akka.http.scaladsl.util.FastFuture instead of scala.concurrent.Future?
The comment says :
/**
* 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.
*/
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?
回答1:
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.
I believe there was a plan to make these improvements part of Scala 2.12, but I never heard of those being concretised.
来源:https://stackoverflow.com/questions/42808593/should-i-use-akka-http-scaladsl-util-fastfuture-instead-of-scala-concurrent-futu