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 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)
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 Futures.traverse.
Simple version of Futures.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.