mirror of https://github.com/panjf2000/ants.git
☄️Rename the function with the more applicable name
This commit is contained in:
parent
3e1c7a03a5
commit
71faec8c1a
|
@ -417,13 +417,13 @@ func TestPurgePreMalloc(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRestCodeCoverage(t *testing.T) {
|
func TestRestCodeCoverage(t *testing.T) {
|
||||||
_, err := ants.NewTimingPool(-1, -1, false)
|
_, err := ants.NewUltimatePool(-1, -1, false)
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
_, err = ants.NewTimingPool(1, -1, false)
|
_, err = ants.NewUltimatePool(1, -1, false)
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
_, err = ants.NewTimingPoolWithFunc(-1, -1, demoPoolFunc, false)
|
_, err = ants.NewUltimatePoolWithFunc(-1, -1, demoPoolFunc, false)
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
_, err = ants.NewTimingPoolWithFunc(1, -1, demoPoolFunc, false)
|
_, err = ants.NewUltimatePoolWithFunc(1, -1, demoPoolFunc, false)
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
|
|
||||||
p0, _ := ants.NewPool(TestSize)
|
p0, _ := ants.NewPool(TestSize)
|
||||||
|
|
8
pool.go
8
pool.go
|
@ -104,16 +104,16 @@ func (p *Pool) periodicallyPurge() {
|
||||||
|
|
||||||
// NewPool generates an instance of ants pool.
|
// NewPool generates an instance of ants pool.
|
||||||
func NewPool(size int) (*Pool, error) {
|
func NewPool(size int) (*Pool, error) {
|
||||||
return NewTimingPool(size, DEFAULT_CLEAN_INTERVAL_TIME, false)
|
return NewUltimatePool(size, DEFAULT_CLEAN_INTERVAL_TIME, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPoolPreMalloc generates an instance of ants pool with the memory pre-allocation of pool size.
|
// NewPoolPreMalloc generates an instance of ants pool with the memory pre-allocation of pool size.
|
||||||
func NewPoolPreMalloc(size int) (*Pool, error) {
|
func NewPoolPreMalloc(size int) (*Pool, error) {
|
||||||
return NewTimingPool(size, DEFAULT_CLEAN_INTERVAL_TIME, true)
|
return NewUltimatePool(size, DEFAULT_CLEAN_INTERVAL_TIME, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTimingPool generates an instance of ants pool with a custom timed task.
|
// NewUltimatePool generates an instance of ants pool with a custom timed task.
|
||||||
func NewTimingPool(size, expiry int, preAlloc bool) (*Pool, error) {
|
func NewUltimatePool(size, expiry int, preAlloc bool) (*Pool, error) {
|
||||||
if size <= 0 {
|
if size <= 0 {
|
||||||
return nil, ErrInvalidPoolSize
|
return nil, ErrInvalidPoolSize
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,16 +107,16 @@ func (p *PoolWithFunc) periodicallyPurge() {
|
||||||
|
|
||||||
// NewPoolWithFunc generates an instance of ants pool with a specific function.
|
// NewPoolWithFunc generates an instance of ants pool with a specific function.
|
||||||
func NewPoolWithFunc(size int, pf func(interface{})) (*PoolWithFunc, error) {
|
func NewPoolWithFunc(size int, pf func(interface{})) (*PoolWithFunc, error) {
|
||||||
return NewTimingPoolWithFunc(size, DEFAULT_CLEAN_INTERVAL_TIME, pf, false)
|
return NewUltimatePoolWithFunc(size, DEFAULT_CLEAN_INTERVAL_TIME, pf, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPoolWithFuncPreMalloc generates an instance of ants pool with a specific function and the memory pre-allocation of pool size.
|
// NewPoolWithFuncPreMalloc generates an instance of ants pool with a specific function and the memory pre-allocation of pool size.
|
||||||
func NewPoolWithFuncPreMalloc(size int, pf func(interface{})) (*PoolWithFunc, error) {
|
func NewPoolWithFuncPreMalloc(size int, pf func(interface{})) (*PoolWithFunc, error) {
|
||||||
return NewTimingPoolWithFunc(size, DEFAULT_CLEAN_INTERVAL_TIME, pf, true)
|
return NewUltimatePoolWithFunc(size, DEFAULT_CLEAN_INTERVAL_TIME, pf, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTimingPoolWithFunc generates an instance of ants pool with a specific function and a custom timed task.
|
// NewUltimatePoolWithFunc generates an instance of ants pool with a specific function and a custom timed task.
|
||||||
func NewTimingPoolWithFunc(size, expiry int, pf func(interface{}), preAlloc bool) (*PoolWithFunc, error) {
|
func NewUltimatePoolWithFunc(size, expiry int, pf func(interface{}), preAlloc bool) (*PoolWithFunc, error) {
|
||||||
if size <= 0 {
|
if size <= 0 {
|
||||||
return nil, ErrInvalidPoolSize
|
return nil, ErrInvalidPoolSize
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue