diff --git a/README.md b/README.md index ce433ed..57fb7db 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ func main() { pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) { request, ok := payload.(*Request) if !ok { - request = Request{Param:[]byte(""), Result: make(chan []byte)} + return } reverseParam := func(s []byte) []byte { for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { diff --git a/README_ZH.md b/README_ZH.md index dc1544d..71501f7 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -118,7 +118,7 @@ func main() { pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) { request, ok := payload.(*Request) if !ok { - request = Request{Param:[]byte(""), Result: make(chan []byte)} + return } reverseParam := func(s []byte) []byte { for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { diff --git a/ants_test.go b/ants_test.go index 385f3a9..699ae88 100644 --- a/ants_test.go +++ b/ants_test.go @@ -71,6 +71,7 @@ func TestAntsPoolWithFunc(t *testing.T) { curMem = mem.TotalAlloc/MiB - curMem t.Logf("memory usage:%d MB", curMem) } + func TestNoPool(t *testing.T) { var wg sync.WaitGroup for i := 0; i < n; i++ {