What is the difference between "Future.successful(None)" and "Future(None)"

Amir Karimi picture Amir Karimi · Jan 30, 2014 · Viewed 9.4k times · Source

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)?

Answer

i.petruk picture i.petruk · Jan 30, 2014

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.