Detach an object from another.
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. However, if the derivative promise is detached before the parent is satisfied, it can just be used as a normal Promise.
The contract for Detachable is to only do non-idempotent side-effects after detaching. Here, the pertinent side-effect is satisfying the Promise.
val f: Future[Unit] val p: Promise[Unit] with Detachable = Promise.attached(f) ... if (p.detach()) p.setValue(())
Single-arg version to avoid object creation and take advantage of forwardInterruptsTo
.
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.