A promise to eventually produce a result of type A. This promise can either be fulfilled or rejected.
Any number of promises can be chained after this one.
actor tag Promise[A: Any #share]
new tag create() : Promise[A] tag^
- Promise[A] tag^
Fulfill the promise.
be apply( value: A)
- value: A
Reject the promise.
Chain a promise after this one.
When this promise is fulfilled, the result of type A is passed to the fulfill function, generating in an intermediate result of type B. This is then used to fulfill the next promise in the chain.
If there is no fulfill function, or if the fulfill function raises an error, then the next promise in the chain will be rejected.
If this promise is rejected, this step's reject function is called with no input, generating an intermediate result of type B which is used to fulfill the next promise in the chain.
If there is no reject function, of if the reject function raises an error, then the next promise in the chain will be rejected.
fun tag next[B: Any #share]( fulfill: Fulfill[A, B] iso, rejected: Reject[B] iso = seq) : Promise[B] tag
- Promise[B] tag
Add two promises into one promise that returns the result of both when they are fulfilled. If either of the promises is rejected then the new promise is also rejected.
fun tag add[optional B: Any #share]( p: Promise[B] tag) : Promise[(A , B)] tag
- p: Promise[B] tag
- Promise[(A , B)] tag
Create a promise that is fulfilled when the receiver and all promises in the given iterator are fulfilled. If the receiver or any promise in the sequence is rejected then the new promise is also rejected.
fun tag join( ps: Iterator[Promise[A] tag] ref) : Promise[Array[A] val] tag
Return a promise that is fulfilled when either promise is fulfilled, resulting in a tuple of its value and the other promise.
fun tag select( p: Promise[A] tag) : Promise[(A , Promise[A] tag)] tag
- p: Promise[A] tag
Reject the promise after the given expiration in nanoseconds.
fun tag timeout( expiration: U64 val) : None val
- expiration: U64 val
- None val
Attaches a step asynchronously. If this promise has already been fulfilled or rejected, immediately fulfill or reject the incoming step. Otherwise, keep it in a list.
be _attach( attach: _IThen[A] iso)
- attach: _IThen[A] iso