class StringCallbackPromise extends Promise[String] with AsyncCallbackPromise[String] with StringCallback
- Alphabetic
- By Inheritance
- StringCallbackPromise
- StringCallback
- AsyncCallback
- AsyncCallbackPromise
- Promise
- Updatable
- Responder
- Future
- Awaitable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new StringCallbackPromise()
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addEventListener(listener: FutureEventListener[_ >: String]): Future[String]
Register a FutureEventListener to be invoked when the computation completes.
Register a FutureEventListener to be invoked when the computation completes. This method is typically used by Java programs because it avoids the use of small Function objects.
- Definition Classes
- Future
- Note
this should be used for side-effects
- See also
respond for a Scala API.
transformedBy for a Java friendly way to produce a new
Future
from the result of a computation.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
become(other: Future[String]): Unit
Become the other promise.
Become the other promise.
become
declares an equivalence relation:this
andother
are the same.By becoming
other
, its waitlists are now merged intothis
's, andthis
becomes canonical. The same is true of interrupt handlers:other
's interrupt handler is overwritten with the handlers installed forthis
.Note: Using
become
andsetInterruptHandler
on the same promise is not recommended. Consider the following, which demonstrates unexpected behavior related to this usage.val a, b = new Promise[Unit] a.setInterruptHandler { case _ => println("A") } b.become(a) b.setInterruptHandler { case _ => println("B") } a.raise(new Exception)
This prints "B", the action in the interrupt handler for
b
, which is unexpected because we raised ona
. In this case and others, using com.twitter.util.Future.proxyTo may be more appropriate.Note that
this
must be unsatisfied at the time of the call, and not race with any other setters.become
is a form of satisfying the promise.This has the combined effect of compressing the
other
intothis
, effectively providing a form of tail-call elimination when used in recursion constructs.transform
(and thus any other combinator) use this to compress Futures, freeing them from space leaks when used with recursive constructions.Note: do not use become with cyclic graphs of futures: the behavior of racing
a.become(b)
withb.become(a)
is undefined (wherea
andb
may resolve as such transitively).- Definition Classes
- Promise
- See also
-
def
before[B](f: ⇒ Future[B])(implicit ev: <:<[StringCallbackPromise.this.type, Future[Unit]]): Future[B]
Sequentially compose
this
withf
. -
def
by(timer: Timer, when: Time, exc: ⇒ Throwable): Future[String]
Returns a new Future that fails if it is not satisfied before the given time.
Returns a new Future that fails if it is not satisfied before the given time.
Note: On timeout, the underlying future is not interrupted.
Note: Interrupting a returned future would not prevent it from being satisfied with a given exception (when the time comes).
- timer
to run timeout on.
- when
indicates when to stop waiting for the result to be available.
- exc
exception to throw.
- Definition Classes
- Future
-
def
by(timer: Timer, when: Time): Future[String]
Returns a new Future that fails if it is not satisfied before the given time.
Returns a new Future that fails if it is not satisfied before the given time.
Note: On timeout, the underlying future is not interrupted.
- Definition Classes
- Future
-
def
by(when: Time)(implicit timer: Timer): Future[String]
Returns a new Future that fails if it is not satisfied before the given time.
Returns a new Future that fails if it is not satisfied before the given time.
Same as the other
by
, but with an implicit timer. Sometimes this is more convenient.Note: On timeout, the underlying future is not interrupted.
- Definition Classes
- Future
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
compress(): Promise[String]
Should only be called when this Promise has already been fulfilled or it is becoming another Future via
become
.Should only be called when this Promise has already been fulfilled or it is becoming another Future via
become
.- Attributes
- protected
- Definition Classes
- Promise
- final def continue(k: K[String]): Unit
-
final
def
continueAll(wq: WaitQueue[String]): Unit
- Attributes
- protected
- Definition Classes
- Responder
-
def
delayed(howlong: Duration)(implicit timer: Timer): Future[String]
Delay the completion of this Future for at least
howlong
from now.Delay the completion of this Future for at least
howlong
from now.Note: Interrupting a returned future would not prevent it from becoming this future (when the time comes).
- Definition Classes
- Future
-
final
def
detach(k: K[String]): Boolean
- Attributes
- protected[com.twitter.util.Promise]
- Definition Classes
- Promise
- Annotations
- @tailrec()
-
def
ensure(f: ⇒ Unit): Future[String]
Invoked regardless of whether the computation completed successfully or unsuccessfully.
Invoked regardless of whether the computation completed successfully or unsuccessfully. Implemented in terms of respond so that subclasses control evaluation order. Returns a chained Future.
The returned
Future
will be satisfied when this, the original future, is done.- f
the side-effect to apply when the computation completes.
- Definition Classes
- Future
import com.twitter.util.Future def callbacks(result: Future[Int]): Future[Int] = result.onSuccess { i => println(i) }.onFailure { e => println(e.getMessage) }.ensure { println("always printed") }
val a = Future.value(1) callbacks(a) // prints "1" and then "always printed"
- Note
this should be used for side-effects.
- See also
respond if you need the result of the computation for usage in the side-effect.
Example: -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
filter(p: (String) ⇒ Boolean): Future[String]
- Definition Classes
- Future
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
flatMap[B](f: (String) ⇒ Future[B]): Future[B]
If this, the original future, succeeds, run
f
on the result.If this, the original future, succeeds, run
f
on the result.The returned result is a Future that is satisfied when the original future and the callback,
f
, are done.- Definition Classes
- Future
import com.twitter.util.{Await, Future} val f: Future[Int] = Future.value(1) val newf: Future[Int] = f.flatMap { x => Future.value(x + 10) } Await.result(newf) // 11 // Await.result blocks the current thread, // don't use it except for tests.
If the original future fails, this one will also fail, without executing
f
and preserving the failed computation ofthis
, import com.twitter.util.{Await, Future} val f: Future[Int] = Future.exception(new Exception("boom!")) val newf: Future[Int] = f.flatMap { x => println("I'm being executed") // won't print Future.value(x + 10) } Await.result(newf) // throws java.lang.Exception: boom!
- See also
Examples: -
def
flatten[B](implicit ev: <:<[String, Future[B]]): Future[B]
Converts a
Future[Future[B]]
into aFuture[B]
.Converts a
Future[Future[B]]
into aFuture[B]
.- Definition Classes
- Future
-
def
foreach(k: (String) ⇒ Unit): Future[String]
Invoke the callback only if the Future returns successfully.
-
final
def
forwardInterruptsTo(other: Future[_]): Unit
Forward interrupts to another future.
Forward interrupts to another future. If the other future is fulfilled, this is a no-op. Calling this multiple times is not recommended as the resulting state may not be as expected.
- other
the Future to which interrupts are forwarded.
- Definition Classes
- Promise
- Annotations
- @tailrec()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
handle[B >: String](rescueException: PartialFunction[Throwable, B]): Future[B]
If this, the original future, results in an exceptional computation,
rescueException
may convert the failure into a new result.If this, the original future, results in an exceptional computation,
rescueException
may convert the failure into a new result.The returned result is a
Future
that is satisfied when the original future and the callback,rescueException
, are done.This is the equivalent of map for failed computations.
- Definition Classes
- Future
import com.twitter.util.{Await, Future} val f1: Future[Int] = Future.exception(new Exception("boom1!")) val f2: Future[Int] = Future.exception(new Exception("boom2!")) val newf: Future[Int] => Future[Int] = x => x.handle { case e: Exception if e.getMessage == "boom1!" => 1 } Await.result(newf(f1)) // 1 Await.result(newf(f2)) // throws java.lang.Exception: boom2! // Await.result blocks the current thread, // don't use it except for tests.
- See also
Example: -
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
interruptible(): Future[String]
Makes a derivative
Future
which will be satisfied with the result of the parent.Makes a derivative
Future
which will be satisfied with the result of the parent. However, if it's interrupted, it will detach from the parentFuture
, satisfy itself with the exception raised to it, and won't propagate the interruption back to the parentFuture
.This is useful for when a
Future
is shared between many contexts, where it may not be useful to discard the underlying computation if just one context is no longer interested in the result. In particular, this is different from Future.masked in that it will prevent memory leaks if the parent Future will never be satisfied, because closures that are attached to this derivativeFuture
will not be held onto by the killerFuture
. -
def
isDefined: Boolean
Is the result of the Future available yet?
-
def
isDone(implicit ev: <:<[StringCallbackPromise.this.type, Future[Unit]]): Boolean
Checks whether a Unit-typed Future is done.
Checks whether a Unit-typed Future is done. By convention, futures of type Future[Unit] are used for signalling.
- Definition Classes
- Future
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isInterrupted: Option[Throwable]
Returns this promise's interrupt if it is interrupted.
Returns this promise's interrupt if it is interrupted.
- Definition Classes
- Promise
-
def
isReady(implicit permit: CanAwait): Boolean
Is this Awaitable ready? In other words: would calling Awaitable.ready block?
Is this Awaitable ready? In other words: would calling Awaitable.ready block?
-
def
join[B](other: Future[B]): Future[(String, B)]
Joins this future with a given
other
future into aFuture[(A, B)]
(future of aTuple2
).Joins this future with a given
other
future into aFuture[(A, B)]
(future of aTuple2
). If this orother
future fails, the returnedFuture
is immediately satisfied by that failure.- Definition Classes
- Future
-
def
joinWith[B, C](other: Future[B])(fn: (String, B) ⇒ C): Future[C]
Joins this future with a given
other
future and appliesfn
to its result.Joins this future with a given
other
future and appliesfn
to its result. If this orother
future fails, the returnedFuture
is immediately satisfied by that failure.Before (using join):
val ab = a.join(b).map { case (a, b) => Foo(a, b) }
After (using joinWith):
val ab = a.joinWith(b)(Foo.apply)
- Definition Classes
- Future
-
def
liftToTry: Future[Try[String]]
Returns the result of the computation as a
Future[Try[A]]
.Returns the result of the computation as a
Future[Try[A]]
.- Definition Classes
- Future
import com.twitter.util.{Await, Future, Try} val fr: Future[Int] = Future.value(1) val ft: Future[Int] = Future.exception(new Exception("boom!")) val r: Future[Try[Int]] = fr.liftToTry val t: Future[Try[Int]] = ft.liftToTry Await.result(r) // Return(1) Await.result(t) // Throw(java.lang.Exception: boom!) // Await.result blocks the current thread, // don't use it except for tests.
Example: -
final
def
link(target: Promise[String]): Unit
- Attributes
- protected
- Definition Classes
- Promise
- Annotations
- @tailrec()
-
def
lowerFromTry[B](implicit ev: <:<[String, Try[B]]): Future[B]
Lowers a
Future[Try[T]]
into aFuture[T]
.Lowers a
Future[Try[T]]
into aFuture[T]
.- Definition Classes
- Future
import com.twitter.util.{Await, Future, Return, Throw, Try} val fr: Future[Try[Int]] = Future.value(Return(1)) val ft: Future[Try[Int]] = Future.value(Throw(new Exception("boom!"))) val r: Future[Int] = fr.lowerFromTry val t: Future[Int] = ft.lowerFromTry Await.result(r) // 1 Await.result(t) // throws java.lang.Exception: boom! // Await.result blocks the current thread, // don't use it except for tests.
Example: -
def
map[B](f: (String) ⇒ B): Future[B]
If this, the original future, succeeds, run
f
on the result.If this, the original future, succeeds, run
f
on the result.The returned result is a Future that is satisfied when the original future and the callback,
f
, are done.- Definition Classes
- Future
import com.twitter.util.{Await, Future} val f: Future[Int] = Future.value(1) val newf: Future[Int] = f.map { x => x + 10 } Await.result(newf) // 11 // Await.result blocks the current thread, // don't use it except for tests.
If the original future fails, this one will also fail, without executing
f
and preserving the failed computation ofthis
, import com.twitter.util.{Await, Future} val f: Future[Int] = Future.exception(new Exception("boom!")) val newf: Future[Int] = f.map { x => println("I'm being executed") // won't print x + 10 } Await.result(newf) // throws java.lang.Exception: boom!
- See also
flatMap for computations that return
Future
s.onSuccess for side-effecting chained computations.
Examples: -
def
mask(pred: PartialFunction[Throwable, Boolean]): Future[String]
Returns an identical
Future
except that it ignores interrupts which match a predicate.Returns an identical
Future
except that it ignores interrupts which match a predicate.This means that a Promise's interrupt handler will not execute on calls to Future.raise for inputs to
pred
that evaluate totrue
. Also,raise
will not be forwarded to chained Futures.For example:
val p = new Promise[Int]() p.setInterruptHandler { case x => println(s"interrupt handler for ${x.getClass}") } val f1: Future[Int] = p.mask { case _: IllegalArgumentException => true } f1.raise(new IllegalArgumentException("ignored!")) // nothing will be printed f1.map(_ + 1).raise(new IllegalArgumentException("ignored!")) // nothing will be printed val f2: Future[Int] = p.mask { case _: IllegalArgumentException => true } f2.raise(new Exception("fire!")) // will print "interrupt handler for class java.lang.Exception"
-
def
masked: Future[String]
Returns an identical
Future
that ignores all interrupts.Returns an identical
Future
that ignores all interrupts.This means that a Promise's interrupt handler will not execute for any call to Future.raise. Also,
raise
will not be forwarded to chained Futures.For example:
import com.twitter.util.{Future, Promise} val p = new Promise[Int]() p.setInterruptHandler { case _ => println("interrupt handler") } val f: Future[Int] = p.masked f.raise(new Exception("ignored!")) // nothing will be printed f1.map(_ + 1).raise(new Exception("ignored!")) // nothing will be printed
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
onFailure(fn: (Throwable) ⇒ Unit): Future[String]
Invoke the function on the error, if the computation was unsuccessful.
Invoke the function on the error, if the computation was unsuccessful. Returns a chained Future as in
respond
.- returns
chained Future
- Definition Classes
- Future
import com.twitter.util.Future def callbacks(result: Future[Int]): Future[Int] = result.onSuccess { i => println(i) }.onFailure { e => println(e.getMessage) }.ensure { println("always printed") }
val b = Future.exception(new Exception("boom!")) callbacks(b) // prints "boom!" and then "always printed"
- Note
this should be used for side-effects.
,if
fn
is aPartialFunction
and the input is not defined for a given Throwable, the resultingMatchError
will propagate to the currentMonitor
. This will happen if you use a construct such asfuture.onFailure { case NonFatal(e) => ... }
when the Throwable is "fatal".- See also
handle and rescue to produce a new
Future
from the result of the computation.
Example: -
def
onSuccess(f: (String) ⇒ Unit): Future[String]
Invoke the function on the result, if the computation was successful.
Invoke the function on the result, if the computation was successful. Returns a chained Future as in
respond
.- returns
chained Future
- Definition Classes
- Future
import com.twitter.util.Future def callbacks(result: Future[Int]): Future[Int] = result.onSuccess { i => println(i) }.onFailure { e => println(e.getMessage) }.ensure { println("always printed") }
val a = Future.value(1) callbacks(a) // prints "1" and then "always printed"
- Note
this should be used for side-effects.
- See also
flatMap and map to produce a new
Future
from the result of the computation.
Example: -
def
or[U >: String](other: Future[U]): Future[U]
A synonym for select: Choose the first
Future
to be satisfied. -
def
poll: Option[Try[String]]
Polls for an available result.
-
def
process(rc: Int, path: String)(result: ⇒ String): Unit
Process result iff rc is OK; otherwise throw a KeeperException.
Process result iff rc is OK; otherwise throw a KeeperException.
- Attributes
- protected
- Definition Classes
- AsyncCallbackPromise
-
def
processResult(rc: Int, path: String, ctx: AnyRef, name: String): Unit
- Definition Classes
- StringCallbackPromise → StringCallback
-
def
proxyTo[B >: String](other: Promise[B]): Unit
Send updates from this Future to the other.
Send updates from this Future to the other.
other
must not yet be satisfied at the time of the call. After this call, nobody else should satisfyother
.- Definition Classes
- Future
- Note
using
proxyTo
will mask interrupts to this future, and it's the user's responsibility to set an interrupt handler onother
to raise on f. In some cases, using com.twitter.util.Promise.become may be more appropriate.- See also
-
final
def
raise(intr: Throwable): Unit
Raise the given throwable as an interrupt.
Raise the given throwable as an interrupt. Interrupts are one-shot and latest-interrupt wins. That is, the last interrupt to have been raised is delivered exactly once to the Promise responsible for making progress on the future (multiple such promises may be involved in
flatMap
chains).Raising an interrupt does not alter the externally observable state of the
Future
. They are used to signal to the producer of the future's value that the result is no longer desired (for whatever reason given in the passedThrowable
). For example:import com.twitter.util.Promise val p = new Promise[Unit]() p.setInterruptHandler { case _ => println("interrupt handler fired") } p.poll // is `None` p.raise(new Exception("raised!")) p.poll // is still `None`
In the context of a
Future
created via composition (e.g.flatMap
/onSuccess
/transform
),raise
-ing on thatFuture
will callraise
on the head of the chain which created thisFuture
. For example:import com.twitter.util.Promise val p = new Promise[Int]() p.setInterruptHandler { case _ => println("interrupt handler fired") } val f = p.map(_ + 1) f.raise(new Exception("fire!"))
The call to
f.raise
will callp.raise
and print "interrupt handler fired".When the head of that chain of
Futures
is satisfied, the nextFuture
in the chain created by composition will haveraise
called. For example:import com.twitter.util.Promise val p1, p2 = new Promise[Int]() p1.setInterruptHandler { case _ => println("p1 interrupt handler") } p2.setInterruptHandler { case _ => println("p2 interrupt handler") } val f = p1.flatMap { _ => p2 } f.raise(new Exception("fire!")) // will print "p1 interrupt handler" p1.setValue(1) // will print "p2 interrupt handler"
-
def
raiseWithin(timer: Timer, timeout: Duration, exc: ⇒ Throwable): Future[String]
Returns a new Future that fails if this Future does not return in time.
Returns a new Future that fails if this Future does not return in time.
Note: On timeout, the underlying future is interrupted.
- Definition Classes
- Future
-
def
raiseWithin(timeout: Duration, exc: ⇒ Throwable)(implicit timer: Timer): Future[String]
Returns a new Future that fails if this Future does not return in time.
Returns a new Future that fails if this Future does not return in time.
Same as the other
raiseWithin
, but with an implicit timer. Sometimes this is more convenient.Note: On timeout, the underlying future is interrupted.
- Definition Classes
- Future
-
def
raiseWithin(timeout: Duration)(implicit timer: Timer): Future[String]
Returns a new Future that fails if this Future does not return in time.
Returns a new Future that fails if this Future does not return in time.
Same as the other
raiseWithin
, but with an implicit timer. Sometimes this is more convenient.Note: On timeout, the underlying future is interrupted.
- Definition Classes
- Future
-
def
ready(timeout: Duration)(implicit permit: CanAwait): StringCallbackPromise.this.type
Support for
Await.ready
. -
def
rescue[B >: String](rescueException: PartialFunction[Throwable, Future[B]]): Future[B]
If this, the original future, results in an exceptional computation,
rescueException
may convert the failure into a new result.If this, the original future, results in an exceptional computation,
rescueException
may convert the failure into a new result.The returned result is a
Future
that is satisfied when the original future and the callback,rescueException
, are done.This is the equivalent of flatMap for failed computations.
- Definition Classes
- Future
import com.twitter.util.{Await, Future} val f1: Future[Int] = Future.exception(new Exception("boom1!")) val f2: Future[Int] = Future.exception(new Exception("boom2!")) val newf: Future[Int] => Future[Int] = x => x.rescue { case e: Exception if e.getMessage == "boom1!" => Future.value(1) } Await.result(newf(f1)) // 1 Await.result(newf(f2)) // throws java.lang.Exception: boom2! // Await.result blocks the current thread, // don't use it except for tests.
- See also
Example: -
def
respond(k: (Try[String]) ⇒ Unit): Future[String]
Note: exceptions in responds are monitored.
-
def
result(timeout: Duration)(implicit permit: CanAwait): String
Support for
Await.result
. -
def
select[U >: String](other: Future[U]): Future[U]
Choose the first Future to be satisfied.
Choose the first Future to be satisfied.
- other
another Future
- returns
a new Future whose result is that of the first of this and other to return
- Definition Classes
- Future
-
def
setDone()(implicit ev: <:<[StringCallbackPromise.this.type, Promise[Unit]]): Boolean
Sets a Unit-typed future.
Sets a Unit-typed future. By convention, futures of type Future[Unit] are used for signalling.
- Definition Classes
- Promise
-
def
setException(throwable: Throwable): Unit
Populate the Promise with the given exception.
Populate the Promise with the given exception.
- Definition Classes
- Promise
- Exceptions thrown
ImmutableResult
if the Promise is already populated
-
final
def
setInterruptHandler(f: PartialFunction[Throwable, Unit]): Unit
(Re)sets the interrupt handler.
(Re)sets the interrupt handler. There is only one active interrupt handler.
- f
the new interrupt handler
- Definition Classes
- Promise
- Annotations
- @tailrec()
-
def
setValue(result: String): Unit
Populate the Promise with the given result.
Populate the Promise with the given result.
- Definition Classes
- Promise
- Exceptions thrown
ImmutableResult
if the Promise is already populated
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toJavaFuture: Future[_ <: String]
Convert a Twitter Future to a Java native Future.
Convert a Twitter Future to a Java native Future. This should match the semantics of a Java Future as closely as possible to avoid issues with the way another API might use them. See:
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html#cancel(boolean)
- Definition Classes
- Future
-
def
toOffer: Offer[Try[String]]
An Offer for this future.
-
def
toString(): String
- Definition Classes
- Promise → AnyRef → Any
-
def
transform[B](f: (Try[String]) ⇒ Future[B]): Future[B]
- Definition Classes
- Responder
-
def
transformTry[B](f: (Try[String]) ⇒ Try[B]): Future[B]
- Attributes
- protected
- Definition Classes
- Responder
-
def
transformedBy[B](transformer: FutureTransformer[String, B]): Future[B]
Transform the
Future[A]
into aFuture[B]
using the FutureTransformer.Transform the
Future[A]
into aFuture[B]
using the FutureTransformer. The FutureTransformer handles both success (Return) and failure (Throw) values by implementingmap
/flatMap
andhandle
/rescue
. This method is typically used by Java programs because it avoids the use of small Function objects.- Definition Classes
- Future
- Note
The FutureTransformer must implement either
flatMap
ormap
and may optionally implementhandle
. Failing to implement a method will result in a run-time error (AbstractMethodError
).- See also
transform for a Scala API.
addEventListener for a Java friendly way to perform side-effects.
-
def
unit: Future[Unit]
Convert this
Future[A]
to aFuture[Unit]
by discarding the result.Convert this
Future[A]
to aFuture[Unit]
by discarding the result.- Definition Classes
- Future
- Note
failed futures will remain as is.
-
def
update(result: Try[String]): Unit
Populate the Promise with the given Try.
-
final
def
updateIfEmpty(result: Try[String]): Boolean
Populate the Promise with the given Try.
Populate the Promise with the given Try. The Try can either be a value or an exception.
setValue
andsetException
are generally more readable methods to use.- returns
true only if the result is updated, false if it was already set.
- Definition Classes
- Promise
- Annotations
- @tailrec()
- Note
Invoking
updateIfEmpty
without checking the boolean result is almost never the right approach. Doing so is generally unsafe unless race conditions are acceptable.
-
def
voided: Future[Void]
Convert this
Future[A]
to aFuture[Void]
by discarding the result.Convert this
Future[A]
to aFuture[Void]
by discarding the result.- Definition Classes
- Future
- Note
failed futures will remain as is.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
willEqual[B](that: Future[B]): Future[Boolean]
Returns a
Future[Boolean]
indicating whether two Futures are equivalent.Returns a
Future[Boolean]
indicating whether two Futures are equivalent.Note that
Future.exception(e).willEqual(Future.exception(e)) == Future.value(true)
.
Future.exception(e).willEqual(Future.exception(e)) == Future.value(true) }}}
- Definition Classes
- Future
-
def
withFilter(p: (String) ⇒ Boolean): Future[String]
- Definition Classes
- Future
-
def
within(timer: Timer, timeout: Duration, exc: ⇒ Throwable): Future[String]
Returns a new Future that fails if it is not satisfied in time.
Returns a new Future that fails if it is not satisfied in time.
Note: On timeout, the underlying future is not interrupted.
- timer
to run timeout on.
- timeout
indicates how long you are willing to wait for the result to be available.
- exc
exception to throw.
- Definition Classes
- Future
-
def
within(timer: Timer, timeout: Duration): Future[String]
Returns a new Future that fails if it is not satisfied in time.
Returns a new Future that fails if it is not satisfied in time.
Note: On timeout, the underlying future is not interrupted.
- Definition Classes
- Future
-
def
within(timeout: Duration)(implicit timer: Timer): Future[String]
Returns a new Future that fails if it is not satisfied in time.
Returns a new Future that fails if it is not satisfied in time.
Same as the other
within
, but with an implicit timer. Sometimes this is more convenient.Note: On timeout, the underlying future is not interrupted.
- Definition Classes
- Future