mirror of
https://github.com/panjf2000/ants.git
synced 2025-12-16 18:11:03 +00:00
Remove the unused error type and update some comments
This commit is contained in:
parent
91b12588db
commit
fdb318c1d7
8
ants.go
8
ants.go
@ -48,12 +48,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Error types for the Ants API.
|
//
|
||||||
//---------------------------------------------------------------------------
|
//--------------------------Error types for the Ants API------------------------------
|
||||||
|
|
||||||
// ErrInvalidPoolSize will be returned when setting a negative number as pool capacity, this error will be only used
|
|
||||||
// by pool with func because pool without func can be infinite by setting up a negative capacity.
|
|
||||||
ErrInvalidPoolSize = errors.New("invalid size for pool")
|
|
||||||
|
|
||||||
// ErrLackPoolFunc will be returned when invokers don't provide function for pool.
|
// ErrLackPoolFunc will be returned when invokers don't provide function for pool.
|
||||||
ErrLackPoolFunc = errors.New("must provide function for pool")
|
ErrLackPoolFunc = errors.New("must provide function for pool")
|
||||||
|
|||||||
4
pool.go
4
pool.go
@ -159,12 +159,12 @@ func (p *Pool) Submit(task func()) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Running returns the number of the currently running goroutines.
|
// Running returns the amount of the currently running goroutines.
|
||||||
func (p *Pool) Running() int {
|
func (p *Pool) Running() int {
|
||||||
return int(atomic.LoadInt32(&p.running))
|
return int(atomic.LoadInt32(&p.running))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free returns the available goroutines to work, -1 indicates this pool is unlimited.
|
// Free returns the amount of available goroutines to work, -1 indicates this pool is unlimited.
|
||||||
func (p *Pool) Free() int {
|
func (p *Pool) Free() int {
|
||||||
c := p.Cap()
|
c := p.Cap()
|
||||||
if c < 0 {
|
if c < 0 {
|
||||||
|
|||||||
@ -176,12 +176,12 @@ func (p *PoolWithFunc) Invoke(args interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Running returns the number of the currently running goroutines.
|
// Running returns the amount of the currently running goroutines.
|
||||||
func (p *PoolWithFunc) Running() int {
|
func (p *PoolWithFunc) Running() int {
|
||||||
return int(atomic.LoadInt32(&p.running))
|
return int(atomic.LoadInt32(&p.running))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free returns an available goroutines to work, -1 indicates this pool is unlimited.
|
// Free returns the amount of available goroutines to work, -1 indicates this pool is unlimited.
|
||||||
func (p *PoolWithFunc) Free() int {
|
func (p *PoolWithFunc) Free() int {
|
||||||
c := p.Cap()
|
c := p.Cap()
|
||||||
if c < 0 {
|
if c < 0 {
|
||||||
@ -242,7 +242,7 @@ func (p *PoolWithFunc) decRunning() {
|
|||||||
atomic.AddInt32(&p.running, -1)
|
atomic.AddInt32(&p.running, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieveWorker returns a available worker to run the tasks.
|
// retrieveWorker returns an available worker to run the tasks.
|
||||||
func (p *PoolWithFunc) retrieveWorker() (w *goWorkerWithFunc) {
|
func (p *PoolWithFunc) retrieveWorker() (w *goWorkerWithFunc) {
|
||||||
spawnWorker := func() {
|
spawnWorker := func() {
|
||||||
w = p.workerCache.Get().(*goWorkerWithFunc)
|
w = p.workerCache.Get().(*goWorkerWithFunc)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user