MCPcopy
hub / github.com/panjf2000/ants / Invoke

Method Invoke

pool_func.go:39–49  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).
39func (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.
52func NewPoolWithFunc(size int, pf func(any), options ...Option) (*PoolWithFunc, error) {

Calls 3

retrieveWorkerMethod · 0.80
inputArgMethod · 0.65
IsClosedMethod · 0.45