From a129a1bbe47b27d9c8e08cadd0e5cf8f8a27626b Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Mon, 19 Aug 2019 16:40:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=85Add=20a=20new=20badge:=20golangci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++++---- README_ZH.md | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 020fad8..c81716a 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ A goroutine pool for Go +
@@ -92,7 +93,7 @@ func main() { fmt.Printf("running goroutines: %d\n", ants.Running()) fmt.Printf("finish all tasks.\n") - // Use the pool with a function, + // Use the pool with a method, // set 10 to the capacity of goroutine pool and 1 second for expired duration. p, _ := ants.NewPoolWithFunc(10, func(i interface{}) { myFunc(i) @@ -172,7 +173,7 @@ ants.Submit(func(){}) ``` ## Customize limited pool -`ants` also supports customizing the capacity of pool. You can invoke the `NewPool` function to instantiate a pool with a given capacity, as following: +`ants` also supports customizing the capacity of pool. You can invoke the `NewPool` method to instantiate a pool with a given capacity, as following: ``` go // Set 10000 the size of goroutine pool @@ -189,14 +190,14 @@ pool.Tune(1000) // Tune its capacity to 1000 pool.Tune(100000) // Tune its capacity to 100000 ``` -Don't worry about the synchronous problems in this case, the function here is thread-safe (or should be called goroutine-safe). +Don't worry about the synchronous problems in this case, the method here is thread-safe (or should be called goroutine-safe). ## Pre-malloc goroutine queue in pool `ants` allows you to pre-allocate memory of goroutine queue in pool, which may get a performance enhancement under some special certain circumstances such as the scenario that requires an pool with ultra-large capacity, meanwhile each task in goroutine lasts for a long time, in this case, pre-mallocing will reduce a lot of costs when re-slicing goroutine queue. ```go -// ants will pre-malloc the whole capacity of pool when you invoke this function +// ants will pre-malloc the whole capacity of pool when you invoke this method p, _ := ants.NewPoolPreMalloc(AntsSize) ``` diff --git a/README_ZH.md b/README_ZH.md index fbe6a0c..61870ce 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -6,6 +6,7 @@ A goroutine pool for Go +