package nnet 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 (p *Pool) SubmitConn(h func()) error { return p.connPool.Submit(h) } func (p *Pool) SubmitWorker(h func()) error { return p.workerPool.Submit(h) }