fixed the "slice bounds out of range" error

This commit is contained in:
andy pan 2018-07-06 14:56:59 +08:00
parent 3e6386d097
commit b21f63142d
2 changed files with 8 additions and 4 deletions

View File

@ -77,8 +77,10 @@ func (p *Pool) monitorAndClear() {
w.stop()
idleWorkers[i] = nil
}
n += 1
p.workers = idleWorkers[n:]
if n > 0 {
n += 1
p.workers = idleWorkers[n:]
}
p.lock.Unlock()
}
}()

View File

@ -78,8 +78,10 @@ func (p *PoolWithFunc) MonitorAndClear() {
w.stop()
idleWorkers[i] = nil
}
n += 1
p.workers = idleWorkers[n:]
if n > 0 {
n += 1
p.workers = idleWorkers[n:]
}
p.lock.Unlock()
}
}()