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) }