wrapAsyncOp adapts a blocking function into the channel-based AsyncOp used internally. The blocking function is invoked synchronously and its result delivered on a buffered channel. The interpreter always invokes an AsyncOp from a dedicated goroutine, so running the blocking call inline here keeps
(fn functions.BlockingAsyncOp)
| 985 | // call inline here keeps the framework to a single goroutine per async call rather than spawning |
| 986 | // an additional one to bridge blocking-to-channel. |
| 987 | func wrapAsyncOp(fn functions.BlockingAsyncOp) functions.AsyncOp { |
| 988 | return func(ctx context.Context, args ...ref.Val) <-chan ref.Val { |
| 989 | ch := make(chan ref.Val, 1) |
| 990 | ch <- fn(ctx, args...) |
| 991 | close(ch) |
| 992 | return ch |
| 993 | } |
| 994 | } |
| 995 | |
| 996 | // LateFunctionBinding indicates that the function has a binding which is not known at compile time. |
| 997 | // This is useful for functions which have side-effects or are not deterministically computable. |
no outgoing calls
no test coverage detected