Object/Class

com.twitter.util

Future

Related Docs: class Future | package util

Permalink

object Future

See also

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

    Analogous to Predef.???

  5. val DEFAULT_TIMEOUT: Duration

    Permalink
  6. val Done: Future[Unit]

    Permalink
  7. val False: Future[Boolean]

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

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

    Permalink
  10. val True: Future[Boolean]

    Permalink
  11. val Unit: Future[Unit]

    Permalink
  12. val Void: Future[Void]

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

    Permalink

    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.

  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.

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

    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

    Makes a Future with a constant result.

  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 an exception).

  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

    Make a Future with an error.

    Make a Future with an error. E.g., Future.exception(new Exception("boo")).

  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

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

    fs

    a java.util.List of Futures

    returns

    a Future[Unit] whose value is populated when all of the fs return.

  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

    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.

    fs

    a sequence of Futures

    returns

    a Future[Unit] whose value is populated when all of the fs return.

  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 new future that can never complete.

  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 rawException[A](e: Throwable): Future[A]

    Permalink

    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.

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

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

    a scala.collection.Seq

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

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

    Permalink

    A unit future that completes after howlong.

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

    Permalink
    Definition Classes
    AnyRef
  66. 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.

  67. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  68. def unapply[A](f: Future[A]): Option[Try[A]]

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

    Permalink

    Make a Future with a constant value.

    Make a Future with a constant value. E.g., Future.value(1) is a Future[Int].

  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.

Deprecated Value Members

  1. def flatten[A](ffa: Future[Future[A]]): Future[A]

    Permalink

    Flattens a nested future.

    Flattens a nested future. Same as ffa.flatten, but easier to call from Java.

    Annotations
    @deprecated
    Deprecated

    (Since version 6.20.1) Use Futures.flatten instead

Inherited from AnyRef

Inherited from Any

Ungrouped