mirror of https://github.com/panjf2000/ants.git
Merge branch 'develop'
This commit is contained in:
commit
f61c696c8f
|
@ -111,8 +111,8 @@ 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
|
// set 10000 the size of goroutine pool and 1 second for expired duration
|
||||||
p, _ := ants.NewPool(10000)
|
p, _ := ants.NewPool(10000, 1)
|
||||||
// submit a task
|
// submit a task
|
||||||
p.Submit(func() {})
|
p.Submit(func() {})
|
||||||
```
|
```
|
||||||
|
|
|
@ -112,7 +112,7 @@ ants.Submit(func() {})
|
||||||
`ants`支持实例化使用者自己的一个 Pool ,指定具体的池容量;通过调用 `NewPool` 方法可以实例化一个新的带有指定容量的 Pool ,如下:
|
`ants`支持实例化使用者自己的一个 Pool ,指定具体的池容量;通过调用 `NewPool` 方法可以实例化一个新的带有指定容量的 Pool ,如下:
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
// set 10000 the size of goroutine pool
|
// set 10000 the size of goroutine pool and 1 second for expired duration
|
||||||
p, _ := ants.NewPool(10000)
|
p, _ := ants.NewPool(10000)
|
||||||
// submit a task
|
// submit a task
|
||||||
p.Submit(func() {})
|
p.Submit(func() {})
|
||||||
|
|
|
@ -100,7 +100,7 @@ func NewPoolWithFunc(size, expiry int, f pf) (*PoolWithFunc, error) {
|
||||||
expiryDuration: time.Duration(expiry) * time.Second,
|
expiryDuration: time.Duration(expiry) * time.Second,
|
||||||
poolFunc: f,
|
poolFunc: f,
|
||||||
}
|
}
|
||||||
p.MonitorAndClear()
|
p.monitorAndClear()
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue