SetAsyncMaxConcurrency sets the maximum concurrency for asynchronous function calls. A non-positive value indicates that concurrency is unbounded.
(n int)
| 305 | // |
| 306 | // A non-positive value indicates that concurrency is unbounded. |
| 307 | func (f *ExecutionFrame) SetAsyncMaxConcurrency(n int) error { |
| 308 | if f.ctx == nil { |
| 309 | return errors.New("asynchronous evaluation options require the execution frame to have a context configured") |
| 310 | } |
| 311 | if n > 0 { |
| 312 | f.ctx.gate.semaphore = make(chan struct{}, n) |
| 313 | } else { |
| 314 | f.ctx.gate.semaphore = nil |
| 315 | } |
| 316 | return nil |
| 317 | } |
| 318 | |
| 319 | // frameStack provides a synchronized pool of ExecutionFrames. |
| 320 | var frameStack = &sync.Pool{ |