Promise α
allows you to create a Task α
whose value is provided later by calling resolve
.
Typical usage is as follows:
let promise ← Promise.new
creates a promisepromise.result? : Task (Option α)
can now be passed aroundpromise.result?.get
blocks until the promise is resolvedpromise.resolve a
resolves the promisepromise.result?.get
now returnssome a
If the promise is dropped without ever being resolved, promise.result?.get
will return none
.
See Promise.result!/resultD
for other ways to handle this case.
Equations
Instances For
Like Promise.result
, but resolves to none
if the promise is dropped without ever being resolved.
The result task of a Promise
.
The task blocks until Promise.resolve
is called. If the promise is dropped without ever being
resolved, evaluating the task will panic and, when not using fatal panics, block forever. Use
Promise.result?
to handle this case explicitly.
Equations
- promise.result! = Task.map IO.Option.getOrBlock!✝ promise.result? Task.Priority.default true
Instances For
The result task of a Promise
.
The task blocks until Promise.resolve
is called. If the promise is dropped without ever being
resolved, evaluating the task will panic and, when not using fatal panics, block forever. Use
Promise.result?
to handle this case explicitly.
Equations
Instances For
Like Promise.result
, but resolves to dflt
if the promise is dropped without ever being resolved.