From 2093372461cb7ce573f2da17321373812c1226f3 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Mon, 3 Dec 2018 14:31:49 +0800 Subject: [PATCH] update example codes of integrating with http server --- README.md | 2 +- README_ZH.md | 2 +- ants_test.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) 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++ {