Analogous to Predef.???
A factory function to "lift" computations into the Future monad.
A factory function to "lift" computations into the Future monad. It will catch nonfatal (see: com.twitter.util.NonFatal) exceptions and wrap them in the Throw[_] type. Non-exceptional values are wrapped in the Return[_] type.
Creates a "batched" Future that, given a function
Seq[In] => Future[Seq[Out]]
, returns a In => Future[Out]
interface
that batches the underlying asynchronous operations.
Creates a "batched" Future that, given a function
Seq[In] => Future[Seq[Out]]
, returns a In => Future[Out]
interface
that batches the underlying asynchronous operations. Thus, one can
incrementally submit tasks to be performed when the criteria for batch
flushing is met.
Example:
val timer = new JavaTimer(true) def processBatch(reqs: Seq[Request]): Future[Seq[Response]] val batcher = Future.batched(sizeThreshold = 10) { processBatch } val response: Future[Response] = batcher(new Request)
batcher
will wait until 10 requests have been submitted, then delegate
to the processBatch
method to compute the responses.
Batchers can be constructed with both size- or time-based thresholds:
val batcher = Future.batched(sizeThreshold = 10, timeThreshold = 10.milliseconds) { ... }
To force the batcher to immediately process all unprocessed requests:
batcher.flushBatch()
A batcher's size can be controlled at runtime with the sizePercentile
function argument. This function returns a float between 0.0 and 1.0,
representing the fractional size of the sizeThreshold
that should be
used for the next batch to be collected.
Collect the results from the given futures into a new future of Seq[A].
Collect the results from the given futures into a new future of Seq[A]. If one or more of the given futures is exceptional, the resulting future result will be the first exception encountered.
TODO: This method should be deprecated in favour of Futures.collect()
.
a java.util.List of Futures
a Future[java.util.List[A]]
containing the collected values from fs.
Collect the results from the given map fs
of futures into a new future
of map.
Collect the results from the given map fs
of futures into a new future
of map. If one or more of the given Futures is exceptional, the resulting Future
result will the first exception encountered.
a map of Futures
a Future[Map[A, B]]
containing the collected values from fs
Collect the results from the given futures into a new future of Seq[A].
Collect the results from the given futures into a new future of Seq[A]. If one or more of the given Futures is exceptional, the resulting Future result will be the first exception encountered.
a sequence of Futures
a Future[Seq[A]]
containing the collected values from fs.
Collect the results from the given futures into a new future of java.util.List[Try[A]].
Collect the results from the given futures into a new future of java.util.List[Try[A]].
TODO: This method should be deprecated in favour of Futures.collectToTry()
.
a java.util.List of Futures
a Future[java.util.List[Try[A]]]
containing the collected values from fs.
Collect the results from the given futures into a new future of Seq[Try[A]].
Collect the results from the given futures into a new future of Seq[Try[A]].
a sequence of Futures
a Future[Seq[Try[A]]]
containing the collected values from fs.
Makes a Future with a constant result.
Produce values from next
until it fails, synchronously
applying body
to each iteration.
Produce values from next
until it fails, synchronously
applying body
to each iteration. The returned future
indicates completion (via an exception).
Make a Future with an error.
Make a Future with an error. E.g., Future.exception(new Exception("boo")).
Take a sequence of Futures, wait till they all complete successfully.
Take a sequence of Futures, wait till they all complete successfully. The future fails immediately if any of the joined Futures do, mimicking the semantics of exceptions.
TODO: This method should be deprecated in favour of Futures.join()
.
a java.util.List of Futures
a Future[Unit] whose value is populated when all of the fs return.
Join 22 futures.
Join 22 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 21 futures.
Join 21 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 20 futures.
Join 20 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 19 futures.
Join 19 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 18 futures.
Join 18 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 17 futures.
Join 17 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 16 futures.
Join 16 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 15 futures.
Join 15 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 14 futures.
Join 14 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 13 futures.
Join 13 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 12 futures.
Join 12 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 11 futures.
Join 11 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 10 futures.
Join 10 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 9 futures.
Join 9 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 8 futures.
Join 8 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 7 futures.
Join 7 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 6 futures.
Join 6 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 5 futures.
Join 5 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 4 futures.
Join 4 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 3 futures.
Join 3 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Join 2 futures.
Join 2 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.
Take a sequence of Futures, wait till they all complete successfully.
Take a sequence of Futures, wait till they all complete successfully. The future fails immediately if any of the joined Futures do, mimicking the semantics of exceptions.
a sequence of Futures
a Future[Unit] whose value is populated when all of the fs return.
Run the computation {{mkFuture}} while installing a monitor that translates any exception thrown into an encoded one.
Run the computation {{mkFuture}} while installing a monitor that translates any exception thrown into an encoded one. If an exception is thrown anywhere, the underlying computation is interrupted with that exception.
This function is usually called to wrap a computation that
returns a Future (f0) whose value is satisfied by the invocation
of an onSuccess/onFailure/ensure callbacks of another future
(f1). If an exception happens in the callbacks on f1, f0 is
never satisfied. In this example, Future.monitored { f1
onSuccess g; f0 }
will cancel f0 so that f0 never hangs.
A new future that can never complete.
Make a Future with an error.
Make a Future with an error. E.g., Future.exception(new Exception("boo")). The exception is not wrapped in any way.
"Select" off the first future to be satisfied.
"Select" off the first future to be satisfied. Return this as a result, with the remainder of the Futures as a sequence.
TODO: This method should be deprecated in favour of Futures.select()
.
a java.util.List
a Future[Tuple2[Try[A], java.util.List[Future[A]]]]
representing the first future
to be satisfied and the rest of the futures.
"Select" off the first future to be satisfied.
"Select" off the first future to be satisfied. Return this as a result, with the remainder of the Futures as a sequence.
a scala.collection.Seq
Select the index into fs
of the first future to be satisfied.
Select the index into fs
of the first future to be satisfied.
cannot be empty
A unit future that completes after howlong
.
Repeat a computation that returns a Future some number of times, after each computation completes.
Make a Future with a constant value.
Make a Future with a constant value. E.g., Future.value(1) is a Future[Int].
Perform the effects of the supplied Future only when the provided flag is true.
Repeat a computation that returns a Future while some predicate obtains, after each computation completes.
Flattens a nested future.
Flattens a nested future. Same as ffa.flatten, but easier to call from Java.
(Since version 6.20.1) Use Futures.flatten instead
(Since version 5.x) Prefer static Future.Void.
Futures for Java-friendly APIs.