Update info and fix typos

This commit is contained in:
Andy Pan 2020-01-25 14:39:27 +08:00
parent 67766a5661
commit d7115c8000
2 changed files with 8 additions and 8 deletions

View File

@ -24,7 +24,7 @@ Library `ants` implements a goroutine pool with fixed capacity, managing and rec
- Managing and recycling a massive number of goroutines automatically - Managing and recycling a massive number of goroutines automatically
- Purging overdue goroutines periodically - Purging overdue goroutines periodically
- Abundant APIs: submitting tasks, getting the number of running goroutines, tuning capacity of pool dynamically, closing pool - Abundant APIs: submitting tasks, getting the number of running goroutines, tuning capacity of pool dynamically, releasing pool, rebooting pool
- Handle panic gracefully to prevent programs from crash - Handle panic gracefully to prevent programs from crash
- Efficient in memory usage and it even achieves [higher performance](#-performance-summary) than unlimited goroutines in Golang - Efficient in memory usage and it even achieves [higher performance](#-performance-summary) than unlimited goroutines in Golang
- Nonblocking mechanism - Nonblocking mechanism
@ -278,7 +278,7 @@ Don't worry about the synchronous problems in this case, the method here is thre
### Pre-malloc goroutine queue in pool ### 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 a 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. `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 a 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 memory allocation in goroutine queue.
```go ```go
// ants will pre-malloc the whole capacity of pool when you invoke this method // ants will pre-malloc the whole capacity of pool when you invoke this method
@ -351,7 +351,7 @@ Please read our [Contributing Guidelines](CONTRIBUTING.md) before opening a PR a
## 📄 License ## 📄 License
Source code in `gnet` is available under the MIT [License](/LICENSE). Source code in `ants` is available under the MIT [License](/LICENSE).
## 📚 Relevant Articles ## 📚 Relevant Articles

View File

@ -24,7 +24,7 @@
- 自动调度海量的 goroutines复用 goroutines - 自动调度海量的 goroutines复用 goroutines
- 定期清理过期的 goroutines进一步节省资源 - 定期清理过期的 goroutines进一步节省资源
- 提供了大量有用的接口:任务提交、获取运行中的 goroutine 数量、动态调整 goroutine 池大小 - 提供了大量有用的接口:任务提交、获取运行中的 goroutine 数量、动态调整 Pool 大小、释放 Pool、重启 Pool
- 优雅处理 panic防止程序崩溃 - 优雅处理 panic防止程序崩溃
- 资源复用,极大节省内存使用量;在大规模批量并发任务场景下比原生 goroutine 并发具有[更高的性能](#-性能小结) - 资源复用,极大节省内存使用量;在大规模批量并发任务场景下比原生 goroutine 并发具有[更高的性能](#-性能小结)
- 非阻塞机制 - 非阻塞机制
@ -279,20 +279,20 @@ pool.Tune(100000) // Tune its capacity to 100000
### 预先分配 goroutine 队列内存 ### 预先分配 goroutine 队列内存
`ants`允许你预先把整个池的容量分配内存, 这个功能可以在某些特定的场景下提高 goroutine 池的性能。比如, 有一个场景需要一个超大容量的池,而且每个 goroutine 里面的任务都是耗时任务,这种情况下,预先分配 goroutine 队列内存将会减少 re-slice 时的复制内存损耗 `ants`允许你预先把整个池的容量分配内存, 这个功能可以在某些特定的场景下提高 goroutine 池的性能。比如, 有一个场景需要一个超大容量的池,而且每个 goroutine 里面的任务都是耗时任务,这种情况下,预先分配 goroutine 队列内存将会减少不必要的内存重新分配
```go ```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 function
p, _ := ants.NewPool(100000, ants.WithPreAlloc(true)) p, _ := ants.NewPool(100000, ants.WithPreAlloc(true))
``` ```
### 销毁 goroutine 池 ### 释放 Pool
```go ```go
pool.Release() pool.Release()
``` ```
### Reboot Pool ### 重启 Pool
```go ```go
// 只要调用 Reboot() 方法,就可以重新激活一个之前已经被销毁掉的池,并且投入使用。 // 只要调用 Reboot() 方法,就可以重新激活一个之前已经被销毁掉的池,并且投入使用。
@ -352,7 +352,7 @@ pool.Reboot()
## 📄 证书 ## 📄 证书
`gnet` 的源码允许用户在遵循 MIT [开源证书](/LICENSE) 规则的前提下使用。 `ants` 的源码允许用户在遵循 MIT [开源证书](/LICENSE) 规则的前提下使用。
## 📚 相关文章 ## 📚 相关文章