SetAsyncMaxConcurrency sets the maximum concurrency for asynchronous function calls. A non-positive value indicates that concurrency is unbounded.
(n int)
| 460 | // |
| 461 | // A non-positive value indicates that concurrency is unbounded. |
| 462 | func (f *ExecutionFrame) SetAsyncMaxConcurrency(n int) error { |
| 463 | if f.ctx == nil { |
| 464 | return errors.New("asynchronous evaluation options require the execution frame to have a context configured") |
| 465 | } |
| 466 | if n > 0 { |
| 467 | f.ctx.gate.semaphore = make(chan struct{}, n) |
| 468 | } else { |
| 469 | f.ctx.gate.semaphore = nil |
| 470 | } |
| 471 | return nil |
| 472 | } |
| 473 | |
| 474 | // frameStack provides a synchronized pool of ExecutionFrames. |
| 475 | var frameStack = &sync.Pool{ |