mirror of https://github.com/panjf2000/ants.git
remove useless return value from pool function
This commit is contained in:
parent
d052cf95e1
commit
d8c168b198
|
@ -36,13 +36,12 @@ const (
|
|||
benchAntsSize = 200000
|
||||
)
|
||||
|
||||
func demoFunc() error {
|
||||
func demoFunc() {
|
||||
n := 10
|
||||
time.Sleep(time.Duration(n) * time.Millisecond)
|
||||
return nil
|
||||
}
|
||||
|
||||
func demoPoolFunc(args interface{}) error {
|
||||
func demoPoolFunc(args interface{}) {
|
||||
//m := args.(int)
|
||||
//var n int
|
||||
//for i := 0; i < m; i++ {
|
||||
|
@ -51,7 +50,6 @@ func demoPoolFunc(args interface{}) error {
|
|||
//return nil
|
||||
n := args.(int)
|
||||
time.Sleep(time.Duration(n) * time.Millisecond)
|
||||
return nil
|
||||
}
|
||||
|
||||
func BenchmarkGoroutineWithFunc(b *testing.B) {
|
||||
|
@ -88,10 +86,9 @@ func BenchmarkSemaphoreWithFunc(b *testing.B) {
|
|||
|
||||
func BenchmarkAntsPoolWithFunc(b *testing.B) {
|
||||
var wg sync.WaitGroup
|
||||
p, _ := ants.NewPoolWithFunc(benchAntsSize, func(i interface{}) error {
|
||||
p, _ := ants.NewPoolWithFunc(benchAntsSize, func(i interface{}) {
|
||||
demoPoolFunc(i)
|
||||
wg.Done()
|
||||
return nil
|
||||
})
|
||||
defer p.Release()
|
||||
|
||||
|
|
|
@ -54,10 +54,9 @@ var curMem uint64
|
|||
|
||||
func TestAntsPoolWithFunc(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
p, _ := ants.NewPoolWithFunc(AntsSize, func(i interface{}) error {
|
||||
p, _ := ants.NewPoolWithFunc(AntsSize, func(i interface{}) {
|
||||
demoPoolFunc(i)
|
||||
wg.Done()
|
||||
return nil
|
||||
})
|
||||
defer p.Release()
|
||||
|
||||
|
@ -94,10 +93,9 @@ func TestAntsPool(t *testing.T) {
|
|||
var wg sync.WaitGroup
|
||||
for i := 0; i < n; i++ {
|
||||
wg.Add(1)
|
||||
ants.Submit(func() error {
|
||||
ants.Submit(func(){
|
||||
demoFunc()
|
||||
wg.Done()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
wg.Wait()
|
||||
|
|
2
pool.go
2
pool.go
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
type sig struct{}
|
||||
|
||||
type f func() error
|
||||
type f func()
|
||||
|
||||
// Pool accept the tasks from client,it limits the total
|
||||
// of goroutines to a given number by recycling goroutines.
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type pf func(interface{}) error
|
||||
type pf func(interface{})
|
||||
|
||||
// PoolWithFunc accept the tasks from client,it limits the total
|
||||
// of goroutines to a given number by recycling goroutines.
|
||||
|
|
Loading…
Reference in New Issue