mirror of https://github.com/panjf2000/ants.git
Fix typos and add comments
This commit is contained in:
parent
8138a23edd
commit
52b301019a
2
pool.go
2
pool.go
|
@ -30,7 +30,7 @@ import (
|
||||||
"github.com/panjf2000/ants/v2/internal"
|
"github.com/panjf2000/ants/v2/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Pool accept the tasks from client, it limits the total of goroutines to a given number by recycling goroutines.
|
// Pool accepts the tasks from client, it limits the total 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
|
||||||
|
|
|
@ -30,7 +30,7 @@ import (
|
||||||
"github.com/panjf2000/ants/v2/internal"
|
"github.com/panjf2000/ants/v2/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PoolWithFunc accept the tasks from client, it limits the total of goroutines to a given number by recycling goroutines.
|
// PoolWithFunc accepts the tasks from client, it limits the total of goroutines to a given number by recycling goroutines.
|
||||||
type PoolWithFunc struct {
|
type PoolWithFunc struct {
|
||||||
// capacity of the pool.
|
// capacity of the pool.
|
||||||
capacity int32
|
capacity int32
|
||||||
|
@ -186,7 +186,7 @@ func (p *PoolWithFunc) Cap() int {
|
||||||
return int(atomic.LoadInt32(&p.capacity))
|
return int(atomic.LoadInt32(&p.capacity))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tune change the capacity of this pool.
|
// Tune changes the capacity of this pool.
|
||||||
func (p *PoolWithFunc) Tune(size int) {
|
func (p *PoolWithFunc) Tune(size int) {
|
||||||
if size < 0 || p.Cap() == size || p.options.PreAlloc {
|
if size < 0 || p.Cap() == size || p.options.PreAlloc {
|
||||||
return
|
return
|
||||||
|
@ -194,7 +194,7 @@ func (p *PoolWithFunc) Tune(size int) {
|
||||||
atomic.StoreInt32(&p.capacity, int32(size))
|
atomic.StoreInt32(&p.capacity, int32(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release Closed this pool.
|
// Release Closes this pool.
|
||||||
func (p *PoolWithFunc) Release() {
|
func (p *PoolWithFunc) Release() {
|
||||||
p.once.Do(func() {
|
p.once.Do(func() {
|
||||||
atomic.StoreInt32(&p.release, 1)
|
atomic.StoreInt32(&p.release, 1)
|
||||||
|
|
|
@ -6,10 +6,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrQueueIsFull ...
|
// ErrQueueIsFull will be returned when the worker queue is full.
|
||||||
ErrQueueIsFull = errors.New("the queue is full")
|
ErrQueueIsFull = errors.New("the queue is full")
|
||||||
|
|
||||||
// ErrQueueLengthIsZero ...
|
// ErrQueueLengthIsZero will be returned when trying to insert item to a released worker queue.
|
||||||
ErrQueueLengthIsZero = errors.New("the queue length is zero")
|
ErrQueueLengthIsZero = errors.New("the queue length is zero")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue