WithMaxGoroutines limits the number of goroutines in a pool. Defaults to unlimited. Panics if n < 1.
(n int)
| 87 | // WithMaxGoroutines limits the number of goroutines in a pool. |
| 88 | // Defaults to unlimited. Panics if n < 1. |
| 89 | func (p *Pool) WithMaxGoroutines(n int) *Pool { |
| 90 | p.panicIfInitialized() |
| 91 | if n < 1 { |
| 92 | panic("max goroutines in a pool must be greater than zero") |
| 93 | } |
| 94 | p.limiter = make(limiter, n) |
| 95 | return p |
| 96 | } |
| 97 | |
| 98 | // init ensures that the pool is initialized before use. This makes the |
| 99 | // zero value of the pool usable. |