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)
| 1070 | // call inline here keeps the framework to a single goroutine per async call rather than spawning |
| 1071 | // an additional one to bridge blocking-to-channel. |
| 1072 | func wrapAsyncOp(fn functions.BlockingAsyncOp) functions.AsyncOp { |
| 1073 | return func(ctx context.Context, args ...ref.Val) <-chan ref.Val { |
| 1074 | ch := make(chan ref.Val, 1) |
| 1075 | ch <- fn(ctx, args...) |
| 1076 | close(ch) |
| 1077 | return ch |
| 1078 | } |
| 1079 | } |
| 1080 | |
| 1081 | // LateFunctionBinding indicates that the function has a binding which is not known at compile time. |
| 1082 | // This is useful for functions which have side-effects or are not deterministically computable. |
no outgoing calls
no test coverage detected