mirror of
https://github.com/panjf2000/ants.git
synced 2025-12-16 18:11:03 +00:00
update
This commit is contained in:
parent
a71bd6bb94
commit
f0d16c0b0a
@ -113,10 +113,10 @@ ants.Submit(func() {})
|
|||||||
Ants also supports custom limited pool. You can use the `NewPool` method to create a pool with the given capacity, as following:
|
Ants also supports custom limited pool. You can use the `NewPool` method to create a pool with the given capacity, as following:
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
// set 10000 the size of goroutine pool and 1 second for expired duration
|
// set 10000 the size of goroutine pool
|
||||||
p, _ := ants.NewPool(10000, 1)
|
p, _ := ants.NewPool(10000)
|
||||||
// submit a task
|
// submit a task
|
||||||
p.Submit(func() {})
|
p.Submit(func() error {})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Readjusting pool capacity
|
## Readjusting pool capacity
|
||||||
|
|||||||
@ -105,15 +105,15 @@ func main() {
|
|||||||
## 任务提交
|
## 任务提交
|
||||||
提交任务通过调用 `ants.Submit(func())`方法:
|
提交任务通过调用 `ants.Submit(func())`方法:
|
||||||
```go
|
```go
|
||||||
ants.Submit(func() {})
|
ants.Submit(func() error {})
|
||||||
```
|
```
|
||||||
|
|
||||||
## 自定义池
|
## 自定义池
|
||||||
`ants`支持实例化使用者自己的一个 Pool ,指定具体的池容量;通过调用 `NewPool` 方法可以实例化一个新的带有指定容量的 Pool ,如下:
|
`ants`支持实例化使用者自己的一个 Pool ,指定具体的池容量;通过调用 `NewPool` 方法可以实例化一个新的带有指定容量的 Pool ,如下:
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
// set 10000 the size of goroutine pool and 1 second for expired duration
|
// set 10000 the size of goroutine pool
|
||||||
p, _ := ants.NewPool(10000, 1)
|
p, _ := ants.NewPool(10000)
|
||||||
// submit a task
|
// submit a task
|
||||||
p.Submit(func() {})
|
p.Submit(func() {})
|
||||||
```
|
```
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user