From 6da1112dffab68138ea08a1b029f3d274a9ba8e8 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Fri, 6 Jul 2018 20:24:47 +0800 Subject: [PATCH] gofmt --- ants.go | 1 - ants_benchmark_test.go | 18 +++++++++--------- examples/main.go | 2 +- pool.go | 9 ++++----- pool_func.go | 10 +++++----- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/ants.go b/ants.go index 78e3b63..adfaed8 100644 --- a/ants.go +++ b/ants.go @@ -68,4 +68,3 @@ var ( ErrPoolSizeInvalid = errors.New("invalid size for pool") ErrPoolClosed = errors.New("this pool has been closed") ) - diff --git a/ants_benchmark_test.go b/ants_benchmark_test.go index 35c83a3..ffff333 100644 --- a/ants_benchmark_test.go +++ b/ants_benchmark_test.go @@ -32,14 +32,14 @@ import ( const ( _ = 1 << (10 * iota) - KiB // 1024 - MiB // 1048576 - GiB // 1073741824 - TiB // 1099511627776 (超过了int32的范围) - PiB // 1125899906842624 - EiB // 1152921504606846976 - ZiB // 1180591620717411303424 (超过了int64的范围) - YiB // 1208925819614629174706176 + KiB // 1024 + MiB // 1048576 + GiB // 1073741824 + TiB // 1099511627776 (超过了int32的范围) + PiB // 1125899906842624 + EiB // 1152921504606846976 + ZiB // 1180591620717411303424 (超过了int64的范围) + YiB // 1208925819614629174706176 ) const RunTimes = 1000000 const loop = 10 @@ -78,7 +78,7 @@ func BenchmarkGoroutineWithFunc(b *testing.B) { func BenchmarkAntsPoolWithFunc(b *testing.B) { var wg sync.WaitGroup - p, _ := ants.NewPoolWithFunc(50000, 1,func(i interface{}) error { + p, _ := ants.NewPoolWithFunc(50000, 1, func(i interface{}) error { demoPoolFunc(i) wg.Done() return nil diff --git a/examples/main.go b/examples/main.go index c9b6aae..f39861e 100644 --- a/examples/main.go +++ b/examples/main.go @@ -51,7 +51,7 @@ func main() { runTimes := 1000 - // use the common pool + // use the common pool var wg sync.WaitGroup for i := 0; i < runTimes; i++ { wg.Add(1) diff --git a/pool.go b/pool.go index 38fe397..8eda8d3 100644 --- a/pool.go +++ b/pool.go @@ -87,16 +87,15 @@ func (p *Pool) monitorAndClear() { }() } - // NewPool generates a instance of ants pool func NewPool(size, expiry int) (*Pool, error) { if size <= 0 { return nil, ErrPoolSizeInvalid } p := &Pool{ - capacity: int32(size), - freeSignal: make(chan sig, math.MaxInt32), - release: make(chan sig, 1), + capacity: int32(size), + freeSignal: make(chan sig, math.MaxInt32), + release: make(chan sig, 1), expiryDuration: time.Duration(expiry) * time.Second, } p.monitorAndClear() @@ -138,7 +137,7 @@ func (p *Pool) Release() error { for i := 0; i < running; i++ { p.getWorker().stop() } - for i := range p.workers{ + for i := range p.workers { p.workers[i] = nil } }) diff --git a/pool_func.go b/pool_func.go index 485ebe1..52e3515 100644 --- a/pool_func.go +++ b/pool_func.go @@ -94,11 +94,11 @@ func NewPoolWithFunc(size, expiry int, f pf) (*PoolWithFunc, error) { return nil, ErrPoolSizeInvalid } p := &PoolWithFunc{ - capacity: int32(size), - freeSignal: make(chan sig, math.MaxInt32), - release: make(chan sig, 1), + capacity: int32(size), + freeSignal: make(chan sig, math.MaxInt32), + release: make(chan sig, 1), expiryDuration: time.Duration(expiry) * time.Second, - poolFunc: f, + poolFunc: f, } p.MonitorAndClear() return p, nil @@ -142,7 +142,7 @@ func (p *PoolWithFunc) Release() error { for i := 0; i < running; i++ { p.getWorker().stop() } - for i := range p.workers{ + for i := range p.workers { p.workers[i] = nil } })