mirror of https://github.com/panjf2000/ants.git
gofmt
This commit is contained in:
parent
a008afdc73
commit
47e2b9efaa
|
@ -20,10 +20,10 @@
|
||||||
package ants_test
|
package ants_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"github.com/panjf2000/ants"
|
"github.com/panjf2000/ants"
|
||||||
"sync"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sync"
|
||||||
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
16
pool.go
16
pool.go
|
@ -19,9 +19,9 @@
|
||||||
package ants
|
package ants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync/atomic"
|
|
||||||
"sync"
|
|
||||||
"math"
|
"math"
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -33,27 +33,27 @@ type f func()
|
||||||
// of goroutines to a given number by recycling goroutines.
|
// of goroutines to a given number by recycling goroutines.
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
// Capacity of the pool.
|
// Capacity of the pool.
|
||||||
capacity int32
|
capacity int32
|
||||||
|
|
||||||
// The number of the currently running goroutines.
|
// The number of the currently running goroutines.
|
||||||
running int32
|
running int32
|
||||||
|
|
||||||
// Signal is used to notice pool there are available
|
// Signal is used to notice pool there are available
|
||||||
// workers which can be sent to work.
|
// workers which can be sent to work.
|
||||||
freeSignal chan sig
|
freeSignal chan sig
|
||||||
|
|
||||||
// A slice that store the available workers.
|
// A slice that store the available workers.
|
||||||
workers []*Worker
|
workers []*Worker
|
||||||
|
|
||||||
workerPool sync.Pool
|
workerPool sync.Pool
|
||||||
|
|
||||||
// It is used to notice the pool to closed itself.
|
// It is used to notice the pool to closed itself.
|
||||||
release chan sig
|
release chan sig
|
||||||
|
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
|
|
||||||
// It is used to confirm whether this pool has been closed.
|
// It is used to confirm whether this pool has been closed.
|
||||||
closed int32
|
closed int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPool(size int) (*Pool, error) {
|
func NewPool(size int) (*Pool, error) {
|
||||||
|
|
Loading…
Reference in New Issue