Starts an asynchronous computation and returns a Future object with the result of that computation.
Starts an asynchronous computation and returns a Future object with the result of that computation.
The result becomes available once the asynchronous computation is completed.
the type of the result
the asychronous computation
the execution context on which the future is run
the Future holding the result of the computation
Creates an already completed Future with the specified exception.
Creates an already completed Future with the specified exception.
the type of the value in the future
the newly created Future object
Returns a Future that will hold the optional result of the first Future with a result that matches the predicate.
Returns a new Future to the result of the first future in the list that is completed.
A non-blocking fold over the specified futures, with the start value of the given zero.
A non-blocking fold over the specified futures, with the start value of the given zero. The fold is performed on the thread where the last future is completed, the result will be the first failure of any of the futures, or any failure in the actual fold, or the result of the fold.
Example:
val result = Await.result(Future.fold(futures)(0)(_ + _), 5 seconds)
Creates an already completed Future with the specified result or exception.
Creates an already completed Future with the specified result or exception.
the type of the value in the promise
the newly created Future object
Initiates a fold over the supplied futures where the fold-zero is the result value of the Future that's completed first.
Initiates a fold over the supplied futures where the fold-zero is the result value of the Future that's completed first.
Example:
val result = Await.result(Future.reduce(futures)(_ + _), 5 seconds)
Simple version of Future.traverse.
Simple version of Future.traverse. Transforms a TraversableOnce[Future[A]] into a Future[TraversableOnce[A]].
Useful for reducing many Futures into a single Future.
Creates an already completed Future with the specified result.
Creates an already completed Future with the specified result.
the type of the value in the future
the newly created Future object
Transforms a TraversableOnce[A] into a Future[TraversableOnce[B]] using the provided function A => Future[B].
Transforms a TraversableOnce[A] into a Future[TraversableOnce[B]] using the provided function A => Future[B].
This is useful for performing a parallel map. For example, to apply a function to all items of a list
in parallel:
val myFutureList = Future.traverse(myList)(x => Future(myFunc(x)))
Future companion object.