github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/utils/gopool.go (about) 1 package utils 2 3 import ( 4 "github.com/panjf2000/ants/v2" 5 "github.com/projecteru2/core/log" 6 ) 7 8 // NewPool new a pool 9 func NewPool(max int) (*ants.PoolWithFunc, error) { 10 return ants.NewPoolWithFunc(max, func(i any) { 11 defer log.SentryDefer() 12 f, _ := i.(func()) 13 f() 14 }, ants.WithNonblocking(true)) 15 }