A template trait for Promises that are derived and capable of being detached from other Promises.
Indicates that an attempt to satisfy a com.twitter.util.Promise was made after that promise had already been satisfied.
Embeds an "interrupt handler" into a Promise.
Embeds an "interrupt handler" into a Promise.
This is a total handler such that it's defined on any Throwable. Use Promise.setInterruptHandler() if you need to leave an interrupt handler undefined for certain types of exceptions.
Example: (p
and q
are equivalent, but p
allocates less):
import com.twitter.util.Promise val p = new Promise[A] with Promise.InterruptHandler { def onInterrupt(t: Throwable): Unit = setException(t) } val q = new Promise[A] q.setInterruptHandler { case t: Throwable => q.setException(t) }
Later calls to setInterruptHandler
on a promise mixing in this
trait will replace the embedded handler.
Create a new, empty, promise of type {{A}}.
Create a derivative promise that will be satisfied with the result of the parent.
Create a derivative promise that will be satisfied with the result of the parent.
If the derivative promise is detached before the parent is satisfied, then it becomes disconnected from the parent and can be used as a normal, unlinked Promise.
By the contract of Detachable
, satisfaction of the Promise must occur
after detachment. Promises should only ever be satisfied after they are
successfully detached (thus satisfaction is the responsibility of the
detacher).
Ex:
val f: Future[Unit] val p: Promise[Unit] with Detachable = Promise.attached(f) ... if (p.detach()) p.setValue(())
Create a promise that interrupts all of fs
.
Create a promise that interrupts all of fs
. In particular:
the returned promise handles an interrupt when any of fs
do.
Future)
interrupts(Future)
Create a promise that interrupts a
and b
futures.
Create a promise that interrupts a
and b
futures. In particular:
the returned promise handles an interrupt when either a
or b
does.
interrupts(Future*)
interrupts(Future)
Single-arg version to avoid object creation and take advantage of forwardInterruptsTo
.
Single-arg version to avoid object creation and take advantage of forwardInterruptsTo
.
interrupts(Future*)
Future)