Add the installation about ants v2

This commit is contained in:
Andy Pan 2019-10-07 19:50:09 +08:00
parent 49150bfa5e
commit 5f1a32384f
2 changed files with 18 additions and 3 deletions

View File

@ -44,10 +44,18 @@ Library `ants` implements a goroutine pool with fixed capacity, managing and rec
## How to install ## How to install
``` sh ### For `ants` v1
``` powershell
go get -u github.com/panjf2000/ants go get -u github.com/panjf2000/ants
``` ```
### For `ants` v2
```powershell
go get -u github.com/panjf2000/ants/v2
```
## How to use ## How to use
Just take a imagination that your program starts a massive number of goroutines, resulting in a huge consumption of memory. To mitigate that kind of situation, all you need to do is to import `ants` package and submit all your tasks to a default pool with fixed capacity, activated when package `ants` is imported: Just take a imagination that your program starts a massive number of goroutines, resulting in a huge consumption of memory. To mitigate that kind of situation, all you need to do is to import `ants` package and submit all your tasks to a default pool with fixed capacity, activated when package `ants` is imported:

View File

@ -42,13 +42,20 @@ A goroutine pool for Go
<img width="1028" alt="ants" src="https://user-images.githubusercontent.com/7496278/66307062-f6859980-e935-11e9-9f30-241c348cbc33.png"> <img width="1028" alt="ants" src="https://user-images.githubusercontent.com/7496278/66307062-f6859980-e935-11e9-9f30-241c348cbc33.png">
</p> </p>
## 安装 ## 安装
``` sh ### 使用 `ants` v1 版本:
``` powershell
go get -u github.com/panjf2000/ants go get -u github.com/panjf2000/ants
``` ```
### 使用 `ants` v2 版本:
```powershell
go get -u github.com/panjf2000/ants/v2
```
## 使用 ## 使用
写 go 并发程序的时候如果程序会启动大量的 goroutine 势必会消耗大量的系统资源内存CPU通过使用 `ants`,可以实例化一个协程池,复用 goroutine ,节省资源,提升性能: 写 go 并发程序的时候如果程序会启动大量的 goroutine 势必会消耗大量的系统资源内存CPU通过使用 `ants`,可以实例化一个协程池,复用 goroutine ,节省资源,提升性能: