ComputeResult tracks and computes the result of the given asynchronous function. The first invocation for a given (node id, args) tuple registers the call state and returns an Unknown which references the call's unique callID. Subsequent invocations return the cached result once the call has comple
(id int64, function, overload string, impl functions.AsyncOp, argVals []ref.Val)
| 238 | // result once the call has completed. Launching background execution is deferred to post-execution |
| 239 | // dispatch via DispatchPendingAsyncCalls. |
| 240 | func (f *ExecutionFrame) ComputeResult(id int64, function, overload string, impl functions.AsyncOp, argVals []ref.Val) ref.Val { |
| 241 | if f.ctx == nil || f.ctx.asyncCalls == nil { |
| 242 | return types.NewErrWithNodeID(id, "asynchronous function calls require concurrent evaluation and cannot be resolved by a synchronous Eval") |
| 243 | } |
| 244 | t := f.ctx.asyncCalls |
| 245 | acs := t.getOrCreate(id, function, overload, argVals, impl, f.ctx.gate) |
| 246 | if res := acs.ResultOrUnknown(); res != nil { |
| 247 | return res |
| 248 | } |
| 249 | return types.NewUnknown(acs.callID, nil) |
| 250 | } |
| 251 | |
| 252 | // DispatchPendingAsyncCalls launches pending asynchronous calls for the specified required call IDs. |
| 253 | func (f *ExecutionFrame) DispatchPendingAsyncCalls(callIDs []int64) { |