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.
nnet/internal/pool/pool.go

28 lines
469 B
Go

package pool
import "github.com/panjf2000/ants/v2"
var _pool *pool
type pool struct {
connPool *ants.Pool
workerPool *ants.Pool
}
func InitPool(size int) {
p := &pool{}
p.connPool, _ = ants.NewPool(size, ants.WithNonblocking(true))
p.workerPool, _ = ants.NewPool(size*2, ants.WithNonblocking(true))
_pool = p
}
func SubmitConn(h func()) error {
return _pool.connPool.Submit(h)
}
func SubmitWorker(h func()) error {
return _pool.workerPool.Submit(h)
}