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

Method Invoke

pool_func_generic.go:34–44  ·  view source on GitHub ↗

Invoke passes the argument to the pool to start a new task.

(arg T)

Source from the content-addressed store, hash-verified

32
33// Invoke passes the argument to the pool to start a new task.
34func (p *PoolWithFuncGeneric[T]) Invoke(arg T) error {
35 if p.IsClosed() {
36 return ErrPoolClosed
37 }
38
39 w, err := p.retrieveWorker()
40 if w != nil {
41 w.(*goWorkerWithFuncGeneric[T]).arg <- arg
42 }
43 return err
44}
45
46// NewPoolWithFuncGeneric instantiates a PoolWithFuncGeneric[T] with customized options.
47func NewPoolWithFuncGeneric[T any](size int, pf func(T), options ...Option) (*PoolWithFuncGeneric[T], error) {

Callers

nothing calls this directly

Calls 2

retrieveWorkerMethod · 0.80
IsClosedMethod · 0.45

Tested by

no test coverage detected