🚀 Updated to fit the refactor

This commit is contained in:
Andy Pan 2019-01-27 00:05:51 +08:00
parent 90f672b9d5
commit c50c1eac23
2 changed files with 20 additions and 6 deletions

View File

@ -171,15 +171,23 @@ p.Submit(func(){})
``` ```
## Tune pool capacity ## Tune pool capacity
You can tune the capacity of `ants` pool at any time with `ReSize(int)`: You can tune the capacity of `ants` pool at any time with `Tune(int)`:
``` go ``` go
pool.ReSize(1000) // Tune its capacity to 1000 pool.Tune(1000) // Tune its capacity to 1000
pool.ReSize(100000) // Tune its capacity to 100000 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 function here is thread-safe (or should be called goroutine-safe).
## Release Pool
```go
pool.Release()
```
## About sequence ## About sequence
All the tasks submitted to `ants` pool will not be guaranteed to be addressed in order, because those tasks scatter among a series of concurrent workers, thus those tasks are executed concurrently. All the tasks submitted to `ants` pool will not be guaranteed to be addressed in order, because those tasks scatter among a series of concurrent workers, thus those tasks are executed concurrently.

View File

@ -171,15 +171,21 @@ p.Submit(func(){})
``` ```
## 动态调整协程池容量 ## 动态调整协程池容量
需要动态调整协程池容量可以通过调用`ReSize(int)` 需要动态调整协程池容量可以通过调用`Tune(int)`
``` go ``` go
pool.ReSize(1000) // Tune its capacity to 1000 pool.Tune(1000) // Tune its capacity to 1000
pool.ReSize(100000) // Tune its capacity to 100000 pool.Tune(100000) // Tune its capacity to 100000
``` ```
该方法是线程安全的。 该方法是线程安全的。
## 销毁协程池
```go
pool.Release()
```
## Benchmarks ## Benchmarks
系统参数: 系统参数: