package taskpool: pop front -> pop back

pull/2/head
q191201771 5 years ago
parent 931637f641
commit 22310c193e

@ -66,4 +66,7 @@ func taskPool() {
func main() { func main() {
taskPool() taskPool()
//originGo() //originGo()
nazalog.Debug("waiting exit.")
time.Sleep(1000 * time.Second)
//nazalog.Debug("bye.")
} }

@ -31,8 +31,11 @@ func (p *pool) Go(task Task) {
// w = e.Value.(*Worker) // w = e.Value.(*Worker)
// p.idleWorkerList.Remove(e) // p.idleWorkerList.Remove(e)
if len(p.idleWorkerList) != 0 { if len(p.idleWorkerList) != 0 {
w = p.idleWorkerList[0] //w = p.idleWorkerList[0]
p.idleWorkerList = p.idleWorkerList[1:] //p.idleWorkerList = p.idleWorkerList[1:]
w = p.idleWorkerList[len(p.idleWorkerList)-1]
p.idleWorkerList = p.idleWorkerList[0:len(p.idleWorkerList)-1]
atomic.AddInt32(&p.idleWorkerNum, -1) atomic.AddInt32(&p.idleWorkerNum, -1)
atomic.AddInt32(&p.busyWorkerNum, 1) atomic.AddInt32(&p.busyWorkerNum, 1)
} }

Loading…
Cancel
Save