🐳 Add test cases for sync.Pool

This commit is contained in:
Andy Pan 2019-01-27 05:07:51 +08:00
parent 840634ae51
commit 822158c59c
1 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ func TestAntsPoolGetWorkerFromCache(t *testing.T) {
for i := 0; i < AntsSize; i++ { for i := 0; i < AntsSize; i++ {
p.Submit(demoFunc) p.Submit(demoFunc)
} }
time.Sleep(ants.DefaultCleanIntervalTime * time.Second) time.Sleep(2 * ants.DefaultCleanIntervalTime * time.Second)
p.Submit(demoFunc) p.Submit(demoFunc)
t.Logf("pool, running workers number:%d", p.Running()) t.Logf("pool, running workers number:%d", p.Running())
mem := runtime.MemStats{} mem := runtime.MemStats{}
@ -100,7 +100,7 @@ func TestAntsPoolWithFuncGetWorkerFromCache(t *testing.T) {
for i := 0; i < AntsSize; i++ { for i := 0; i < AntsSize; i++ {
p.Serve(dur) p.Serve(dur)
} }
time.Sleep(ants.DefaultCleanIntervalTime * time.Second) time.Sleep(2 * ants.DefaultCleanIntervalTime * time.Second)
p.Serve(dur) p.Serve(dur)
t.Logf("pool, running workers number:%d", p.Running()) t.Logf("pool, running workers number:%d", p.Running())
mem := runtime.MemStats{} mem := runtime.MemStats{}