Skip to content

Commit

Permalink
Update info and fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Jan 25, 2020
1 parent 67766a5 commit d7115c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
- Efficient in memory usage and it even achieves [higher performance](#-performance-summary) than unlimited goroutines in Golang
- Nonblocking mechanism
Expand Down Expand Up @@ -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

`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
// ants will pre-malloc the whole capacity of pool when you invoke this method
Expand Down Expand Up @@ -351,7 +351,7 @@ Please read our [Contributing Guidelines](CONTRIBUTING.md) before opening a PR a

## 📄 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

Expand Down
10 changes: 5 additions & 5 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

- 自动调度海量的 goroutines,复用 goroutines
- 定期清理过期的 goroutines,进一步节省资源
- 提供了大量有用的接口:任务提交、获取运行中的 goroutine 数量、动态调整 goroutine 池大小
- 提供了大量有用的接口:任务提交、获取运行中的 goroutine 数量、动态调整 Pool 大小、释放 Pool、重启 Pool
- 优雅处理 panic,防止程序崩溃
- 资源复用,极大节省内存使用量;在大规模批量并发任务场景下比原生 goroutine 并发具有[更高的性能](#-性能小结)
- 非阻塞机制
Expand Down Expand Up @@ -279,20 +279,20 @@ pool.Tune(100000) // Tune its capacity to 100000

### 预先分配 goroutine 队列内存

`ants`允许你预先把整个池的容量分配内存, 这个功能可以在某些特定的场景下提高 goroutine 池的性能。比如, 有一个场景需要一个超大容量的池,而且每个 goroutine 里面的任务都是耗时任务,这种情况下,预先分配 goroutine 队列内存将会减少 re-slice 时的复制内存损耗
`ants`允许你预先把整个池的容量分配内存, 这个功能可以在某些特定的场景下提高 goroutine 池的性能。比如, 有一个场景需要一个超大容量的池,而且每个 goroutine 里面的任务都是耗时任务,这种情况下,预先分配 goroutine 队列内存将会减少不必要的内存重新分配

```go
// ants will pre-malloc the whole capacity of pool when you invoke this function
p, _ := ants.NewPool(100000, ants.WithPreAlloc(true))
```

### 销毁 goroutine 池
### 释放 Pool

```go
pool.Release()
```

### Reboot Pool
### 重启 Pool

```go
// 只要调用 Reboot() 方法,就可以重新激活一个之前已经被销毁掉的池,并且投入使用。
Expand Down Expand Up @@ -352,7 +352,7 @@ pool.Reboot()

## 📄 证书

`gnet` 的源码允许用户在遵循 MIT [开源证书](/LICENSE) 规则的前提下使用。
`ants` 的源码允许用户在遵循 MIT [开源证书](/LICENSE) 规则的前提下使用。

## 📚 相关文章

Expand Down

0 comments on commit d7115c8

Please sign in to comment.