mirror of https://github.com/panjf2000/ants.git
optimization for default pool
This commit is contained in:
parent
9af581c867
commit
87b15034c5
14
ants.go
14
ants.go
|
@ -48,15 +48,6 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release Closed the default pool
|
|
||||||
func Release() {
|
|
||||||
defaultAntsPool.Release()
|
|
||||||
defaultAntsPool, err = NewPool(DefaultAntsPoolSize)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Submit submit a task to pool
|
// Submit submit a task to pool
|
||||||
func Submit(task f) error {
|
func Submit(task f) error {
|
||||||
return defaultAntsPool.Submit(task)
|
return defaultAntsPool.Submit(task)
|
||||||
|
@ -77,6 +68,11 @@ func Free() int {
|
||||||
return defaultAntsPool.Free()
|
return defaultAntsPool.Free()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release Closed the default pool
|
||||||
|
func Release() {
|
||||||
|
defaultAntsPool.Release()
|
||||||
|
}
|
||||||
|
|
||||||
// Errors for the Ants API
|
// Errors for the Ants API
|
||||||
var (
|
var (
|
||||||
ErrInvalidPoolSize = errors.New("invalid size for pool")
|
ErrInvalidPoolSize = errors.New("invalid size for pool")
|
||||||
|
|
Loading…
Reference in New Issue