Commit f8a04498 authored by AlexStocks's avatar AlexStocks

Fix: add go for every pool worker

parent a9e318f8
......@@ -69,11 +69,11 @@ func (p *taskPool) start() {
p.qArray[i] = make(chan task, p.qLen)
p.wg.Add(1)
taskID := i
p.run(int(taskID))
go p.run(int(taskID))
}
}
// task
// worker
func (p *taskPool) run(id int) {
defer p.wg.Done()
......@@ -85,8 +85,11 @@ func (p *taskPool) run(id int) {
for {
select {
case <-p.done:
log.Warn("[getty][task_pool] task %d exit now while its task length is %d",
id, len(p.qArray[id]))
if 0 < len(p.qArray[id]) {
log.Warn("[getty][task_pool] task %d exit now while its task length is %d greater than 0",
id, len(p.qArray[id]))
}
log.Info("[getty][task_pool] task %d exit now", id)
return
case t, ok = <-p.qArray[id]:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment