You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool/npool/pool.go

41 lines
549 B
Go

package npool
import (
"github.com/panjf2000/ants/v2"
"math"
)
var antsPool *ants.Pool
func init() {
antsPool, _ = ants.NewPool(math.MaxInt32)
}
func InitPool(config Config) {
antsPool, _ = ants.NewPool(config.PoolSize, ants.WithOptions(config.Options()))
}
func Submit(task func()) error {
return antsPool.Submit(task)
}
func Running() int {
return antsPool.Running()
}
func Cap() int {
return antsPool.Cap()
}
func Free() int {
return antsPool.Free()
}
func Release() {
antsPool.Release()
}
func Reboot() {
antsPool.Reboot()
}