Future.apply
starts an asynchronous computation whereas Future.successful
creates an already completed Future with the specified result.
Now is Future(None)
(Future.apply(None)
) less efficient than Future.successful(None)
?
It is used for performing operations concurrently, in a non-blocking manner, and it enables scaling workloads efficiently across shared resources. The Future. successful method constructs an already completed Future with the specified result. The fact that the Future can be completed immediately is more efficient.
A Future is a placeholder object for a value that may not yet exist. Generally, the value of the Future is supplied concurrently and can subsequently be used. Composing concurrent tasks in this way tends to result in faster, asynchronous, non-blocking parallel code.
Future.apply(None)
creates asynchronous computation and executes it. It means that extra lambda object is created and extra task is scheduled (however trivial task).
Future.successful(None)
just produces already completed future. It is more efficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With