func (p *Pool) KillWorker(id string) bool {
	p.mux.Lock()
	defer p.mux.Unlock()
	if w, ok := p.workerMap[id]; ok {
		w.cancel()
		delete(p.workerMap, id)
		for i := range p.workers {
			if p.workers[i].id == id {
				p.workers = append(p.workers[:i], p.workers[i+1:]...)
				break
			}
		}
		go func() {
			<-w.closed
			p.mux.Lock()
			defer p.mux.Unlock()
			p.startWorker()
		}()
		return true
	}
	return false
}
// KillWorker kills the worker with given id, causing the pool to
// respawn a new worker.
// KillWorker returns false if there was no such worker.
KillWorker kills the worker with given id, causing the pool to
respawn a new worker.
KillWorker returns false if there was no such worker.
// KillWorker kills the worker with given id causing the pool to // respawn a new worker . // KillWorker returns false if there was no such worker .
func (p *Pool) KillWorker(id string) bool {
	p.mux.Lock()
	defer p.mux.Unlock()
	if w, ok := p.workerMap[id]; ok {
		w.cancel()
		delete(p.workerMap, id)
		for i := range p.workers {
			if p.workers[i].id == id {
				p.workers = append(p.workers[:i], p.workers[i+1:]...)
				break
			}
		}
		go func() {
			<-w.closed
			p.mux.Lock()
			defer p.mux.Unlock()
			p.startWorker()
		}()
		return true
	}
	return false
}
func ( p * Pool ) KillWorker ( id string ) bool { p . mux . Lock ( ) defer p . mux . Unlock ( ) if w , ok := p . workerMap [ id ] ; ok { w . cancel ( ) delete ( p . workerMap , id ) for i := range p . workers { if p . workers [ i ] . id == id { p . workers = append ( p . workers [ : i ] , p . workers [ i + 1 : ] ... ) break } } go func ( ) { <- w . closed p . mux . Lock ( ) defer p . mux . Unlock ( ) p . startWorker ( ) } ( ) return true } return false }
KillWorker kills the worker with given id, causing the pool to
respawn a new worker.
KillWorker kills the worker with given id causing the pool to respawn a new worker .