Invoke passes arguments to the pool. Note that you are allowed to call Pool.Invoke() from the current Pool.Invoke(), but what calls for special attention is that you will get blocked with the last Pool.Invoke() call once the current Pool runs out of its capacity, and to avoid this, you should insta
(arg any)
| 37 | // Pool.Invoke() call once the current Pool runs out of its capacity, and to avoid this, |
| 38 | // you should instantiate a PoolWithFunc with ants.WithNonblocking(true). |
| 39 | func (p *PoolWithFunc) Invoke(arg any) error { |
| 40 | if p.IsClosed() { |
| 41 | return ErrPoolClosed |
| 42 | } |
| 43 | |
| 44 | w, err := p.retrieveWorker() |
| 45 | if w != nil { |
| 46 | w.inputArg(arg) |
| 47 | } |
| 48 | return err |
| 49 | } |
| 50 | |
| 51 | // NewPoolWithFunc instantiates a PoolWithFunc with customized options. |
| 52 | func NewPoolWithFunc(size int, pf func(any), options ...Option) (*PoolWithFunc, error) { |