Object/Class

com.twitter.util

Future

Related Docs: class Future | package util

Permalink

object Future

See also

The user guide on concurrent programming with Futures.

Futures for Java-friendly APIs.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Future
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. case class NextThrewException(cause: Throwable) extends IllegalArgumentException with Product with Serializable

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val ???: Future[Nothing]

    Permalink

    A failed Future analogous to Predef.???.

  5. val DEFAULT_TIMEOUT: Duration

    Permalink
  6. val Done: Future[Unit]

    Permalink

    A successfully satisfied constant Unit-typed Future of ()

  7. val False: Future[Boolean]

    Permalink

    A successfully satisfied constant Future of false

  8. val Nil: Future[Seq[Nothing]]

    Permalink

    A successfully satisfied constant Future of Nil

  9. val None: Future[Option[Nothing]]

    Permalink

    A successfully satisfied constant Future of None

  10. val True: Future[Boolean]

    Permalink

    A successfully satisfied constant Future of true

  11. val Unit: Future[Unit]

    Permalink

    A successfully satisfied constant Unit-typed Future of ()

  12. val Void: Future[Void]

    Permalink

    A successfully satisfied constant Future of Void-type.

    A successfully satisfied constant Future of Void-type. Can be useful for Java programmers.

  13. def apply[A](a: ⇒ A): Future[A]

    Permalink

    Creates a satisfied Future from the result of running a.

    Creates a satisfied Future from the result of running a.

    If the result of a is a non-fatal exception, this will result in a failed Future. Otherwise, the result is a successfully satisfied Future.

    Note

    that a is executed in the calling thread and as such some care must be taken with blocking code.

  14. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  15. def batched[In, Out](sizeThreshold: Int, timeThreshold: Duration = Duration.Top, sizePercentile: ⇒ Float = 1.0f)(f: (Seq[In]) ⇒ Future[Seq[Out]])(implicit timer: Timer): Batcher[In, Out]

    Permalink

    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.

  16. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  17. def collect[A](fs: List[Future[A]]): Future[List[A]]

    Permalink

    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().

    fs

    a java.util.List of Futures

    returns

    a Future[java.util.List[A]] containing the collected values from fs.

  18. def collect[A, B](fs: Map[A, Future[B]]): Future[Map[A, B]]

    Permalink

    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.

    fs

    a map of Futures

    returns

    a Future[Map[A, B]] containing the collected values from fs

  19. def collect[A](fs: Seq[Future[A]]): Future[Seq[A]]

    Permalink

    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.

    fs

    a sequence of Futures

    returns

    a Future[Seq[A]] containing the collected values from fs.

    See also

    join if you are not interested in the results of the individual Futures, only when they are complete.

    collectToTry if you want to be able to see the results of each Future regardless of if they succeed or fail.

  20. def collectToTry[A](fs: List[Future[A]]): Future[List[Try[A]]]

    Permalink

    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().

    fs

    a java.util.List of Futures

    returns

    a Future[java.util.List[Try[A]]] containing the collected values from fs.

  21. def collectToTry[A](fs: Seq[Future[A]]): Future[Seq[Try[A]]]

    Permalink

    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]].

    The returned Future is satisfied when all of the given Futures have been satisfied.

    fs

    a sequence of Futures

    returns

    a Future[Seq[Try[A]]] containing the collected values from fs.

  22. def const[A](result: Try[A]): Future[A]

    Permalink

    Creates a satisfied Future from a Try.

    Creates a satisfied Future from a Try.

    See also

    exception for creation from a Throwable.

    apply for creation from a Function.

    value for creation from a constant value.

  23. def each[A](next: ⇒ Future[A])(body: (A) ⇒ Unit): Future[Nothing]

    Permalink

    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 a failed Future.

  24. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  25. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  26. def exception[A](e: Throwable): Future[A]

    Permalink

    Creates a failed satisfied Future.

    Creates a failed satisfied Future.

    For example,

    Future.exception(new Exception("boo"))

    .

    Future.exception(new Exception("boo")) }}}

    See also

    apply for creation from a Function.

  27. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  28. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  29. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  30. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  31. def join[A](fs: List[Future[A]]): Future[Unit]

    Permalink

    Creates a Future that is satisfied when all futures in fs are successfully satisfied.

    Creates a Future that is satisfied when all futures in fs are successfully satisfied. If any of the futures in fs fail, the returned Future is immediately satisfied by that failure.

    TODO: This method should be deprecated in favour of Futures.join().

    fs

    a java.util.List of Futures

    See also

    collectToTry if you want to be able to see the results of each Future regardless of if they succeed or fail.

    collect if you want to be able to see the results of each Future.

    Futures.join for a Java friendly API.

  32. def join[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M], n: Future[N], o: Future[O], p: Future[P], q: Future[Q], r: Future[R], s: Future[S], t: Future[T], u: Future[U], v: Future[V]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)]

    Permalink

    Join 22 futures.

    Join 22 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  33. def join[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M], n: Future[N], o: Future[O], p: Future[P], q: Future[Q], r: Future[R], s: Future[S], t: Future[T], u: Future[U]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)]

    Permalink

    Join 21 futures.

    Join 21 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  34. def join[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M], n: Future[N], o: Future[O], p: Future[P], q: Future[Q], r: Future[R], s: Future[S], t: Future[T]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)]

    Permalink

    Join 20 futures.

    Join 20 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  35. def join[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M], n: Future[N], o: Future[O], p: Future[P], q: Future[Q], r: Future[R], s: Future[S]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)]

    Permalink

    Join 19 futures.

    Join 19 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  36. def join[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M], n: Future[N], o: Future[O], p: Future[P], q: Future[Q], r: Future[R]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)]

    Permalink

    Join 18 futures.

    Join 18 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  37. def join[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M], n: Future[N], o: Future[O], p: Future[P], q: Future[Q]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)]

    Permalink

    Join 17 futures.

    Join 17 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  38. def join[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M], n: Future[N], o: Future[O], p: Future[P]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)]

    Permalink

    Join 16 futures.

    Join 16 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  39. def join[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M], n: Future[N], o: Future[O]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)]

    Permalink

    Join 15 futures.

    Join 15 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  40. def join[A, B, C, D, E, F, G, H, I, J, K, L, M, N](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M], n: Future[N]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)]

    Permalink

    Join 14 futures.

    Join 14 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  41. def join[A, B, C, D, E, F, G, H, I, J, K, L, M](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L], m: Future[M]): Future[(A, B, C, D, E, F, G, H, I, J, K, L, M)]

    Permalink

    Join 13 futures.

    Join 13 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  42. def join[A, B, C, D, E, F, G, H, I, J, K, L](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K], l: Future[L]): Future[(A, B, C, D, E, F, G, H, I, J, K, L)]

    Permalink

    Join 12 futures.

    Join 12 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  43. def join[A, B, C, D, E, F, G, H, I, J, K](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J], k: Future[K]): Future[(A, B, C, D, E, F, G, H, I, J, K)]

    Permalink

    Join 11 futures.

    Join 11 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  44. def join[A, B, C, D, E, F, G, H, I, J](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I], j: Future[J]): Future[(A, B, C, D, E, F, G, H, I, J)]

    Permalink

    Join 10 futures.

    Join 10 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  45. def join[A, B, C, D, E, F, G, H, I](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H], i: Future[I]): Future[(A, B, C, D, E, F, G, H, I)]

    Permalink

    Join 9 futures.

    Join 9 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  46. def join[A, B, C, D, E, F, G, H](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G], h: Future[H]): Future[(A, B, C, D, E, F, G, H)]

    Permalink

    Join 8 futures.

    Join 8 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  47. def join[A, B, C, D, E, F, G](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F], g: Future[G]): Future[(A, B, C, D, E, F, G)]

    Permalink

    Join 7 futures.

    Join 7 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  48. def join[A, B, C, D, E, F](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E], f: Future[F]): Future[(A, B, C, D, E, F)]

    Permalink

    Join 6 futures.

    Join 6 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  49. def join[A, B, C, D, E](a: Future[A], b: Future[B], c: Future[C], d: Future[D], e: Future[E]): Future[(A, B, C, D, E)]

    Permalink

    Join 5 futures.

    Join 5 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  50. def join[A, B, C, D](a: Future[A], b: Future[B], c: Future[C], d: Future[D]): Future[(A, B, C, D)]

    Permalink

    Join 4 futures.

    Join 4 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  51. def join[A, B, C](a: Future[A], b: Future[B], c: Future[C]): Future[(A, B, C)]

    Permalink

    Join 3 futures.

    Join 3 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  52. def join[A, B](a: Future[A], b: Future[B]): Future[(A, B)]

    Permalink

    Join 2 futures.

    Join 2 futures. The returned future is complete when all underlying futures complete. It fails immediately if any of them do.

  53. def join[A](fs: Seq[Future[A]]): Future[Unit]

    Permalink

    Creates a Future that is satisfied when all futures in fs are successfully satisfied.

    Creates a Future that is satisfied when all futures in fs are successfully satisfied. If any of the futures in fs fail, the returned Future is immediately satisfied by that failure.

    fs

    a sequence of Futures

    See also

    collectToTry if you want to be able to see the results of each Future regardless of if they succeed or fail.

    collect if you want to be able to see the results of each Future.

    Futures.join for a Java friendly API.

  54. def monitored[A](mkFuture: ⇒ Future[A]): Future[A]

    Permalink

    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.

  55. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  56. val never: Future[Nothing]

    Permalink

    A Future that can never be satisfied.

  57. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  58. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  59. def parallel[A](n: Int)(f: ⇒ Future[A]): Seq[Future[A]]

    Permalink
  60. def select[A](fs: List[Future[A]]): Future[(Try[A], List[Future[A]])]

    Permalink

    "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().

    fs

    a java.util.List

    returns

    a Future[Tuple2[Try[A], java.util.List[Future[A]]]] representing the first future to be satisfied and the rest of the futures.

  61. def select[A](fs: Seq[Future[A]]): Future[(Try[A], Seq[Future[A]])]

    Permalink

    "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.

    fs

    the futures to select from. Must not be empty.

    See also

    selectIndex which can be more performant in some situations.

  62. def selectIndex[A](fs: IndexedSeq[Future[A]]): Future[Int]

    Permalink

    Select the index into fs of the first future to be satisfied.

    Select the index into fs of the first future to be satisfied.

    fs

    cannot be empty

    See also

    select which can be an easier API to use.

  63. def sleep(howlong: Duration)(implicit timer: Timer): Future[Unit]

    Permalink

    A Unit-typed Future that is satisfied after howlong.

  64. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  65. def times[A](n: Int)(f: ⇒ Future[A]): Future[Unit]

    Permalink

    Repeat a computation that returns a Future some number of times, after each computation completes.

  66. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  67. def traverseSequentially[A, B](as: Seq[A])(f: (A) ⇒ Future[B]): Future[Seq[B]]

    Permalink

    Take a sequence and sequentially apply a function f to each item.

    Take a sequence and sequentially apply a function f to each item. Then return all future results as as a single Future[Seq[_]].

    If during execution any f is satisfied as as a failure (Future.exception) then that failed Future will be returned and the remaining elements of as will not be processed.

    usage:

    // will return a Future of `Seq(2, 3, 4)`
    Future.traverseSequentially(Seq(1, 2, 3)) { i =>
      Future(i + 1)
    }
    returns

    a Future[Seq[B]] containing the results of f being applied to every item in as

  68. def unapply[A](f: Future[A]): Option[Try[A]]

    Permalink
  69. def value[A](a: A): Future[A]

    Permalink

    Creates a successful satisfied Future from the value a.

    Creates a successful satisfied Future from the value a.

    See also

    exception for creation from a Throwable.

    apply for creation from a Function.

    const for creation from a Try

  70. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  71. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  72. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  73. def when[A](p: Boolean)(f: ⇒ Future[A]): Future[Unit]

    Permalink

    Perform the effects of the supplied Future only when the provided flag is true.

  74. def whileDo[A](p: ⇒ Boolean)(f: ⇒ Future[A]): Future[Unit]

    Permalink

    Repeat a computation that returns a Future while some predicate obtains, after each computation completes.

Inherited from AnyRef

Inherited from Any

Ungrouped