func (p *Pool) Resize(n int) {
	p.mux.Lock()
	defer p.mux.Unlock()
	if l := len(p.workers); l < n {
		for i := 0; i < n-l; i++ {
			p.startWorker()
		}
	} else if l > n {
		for i := 0; i < l-n; i++ {
			p.workers[i].cancel()
			delete(p.workerMap, p.workers[i].id)
		}
		p.workers = p.workers[l-n:]
	}
}
// Resize changes active worker count.
// If given n is greater than current worker count,
// it starts new workers. If given n is less than current
// worker count, it cancels running workers' context.
// This method is concurrent-safe.
Resize changes active worker count.
If given n is greater than current worker count,
it starts new workers. If given n is less than current
worker count, it cancels running workers' context.
This method is concurrent-safe.
// Resize changes active worker count . // If given n is greater than current worker count // it starts new workers . If given n is less than current // worker count it cancels running workers ' context . // This method is concurrent - safe .
func (p *Pool) Resize(n int) {
	p.mux.Lock()
	defer p.mux.Unlock()
	if l := len(p.workers); l < n {
		for i := 0; i < n-l; i++ {
			p.startWorker()
		}
	} else if l > n {
		for i := 0; i < l-n; i++ {
			p.workers[i].cancel()
			delete(p.workerMap, p.workers[i].id)
		}
		p.workers = p.workers[l-n:]
	}
}
func ( p * Pool ) Resize ( n int ) { p . mux . Lock ( ) defer p . mux . Unlock ( ) if l := len ( p . workers ) ; l < n { for i := 0 ; i < n - l ; i ++ { p . startWorker ( ) } } else if l > n { for i := 0 ; i < l - n ; i ++ { p . workers [ i ] . cancel ( ) delete ( p . workerMap , p . workers [ i ] . id ) } p . workers = p . workers [ l - n : ] } }
Resize changes active worker count.
Resize changes active worker count .