forked from mirror/ants
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 (
|
||||
// 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")
|
||||
//
|
||||
//--------------------------Error types for the Ants API------------------------------
|
||||
|
||||
// ErrLackPoolFunc will be returned when invokers don't 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
|
||||
}
|
||||
|
||||
// Running returns the number of the currently running goroutines.
|
||||
// Running returns the amount of the currently running goroutines.
|
||||
func (p *Pool) Running() int {
|
||||
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 {
|
||||
c := p.Cap()
|
||||
if c < 0 {
|
||||
|
|
|
@ -176,12 +176,12 @@ func (p *PoolWithFunc) Invoke(args interface{}) error {
|
|||
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 {
|
||||
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 {
|
||||
c := p.Cap()
|
||||
if c < 0 {
|
||||
|
@ -242,7 +242,7 @@ func (p *PoolWithFunc) decRunning() {
|
|||
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) {
|
||||
spawnWorker := func() {
|
||||
w = p.workerCache.Get().(*goWorkerWithFunc)
|
||||
|
|
Loading…
Reference in New Issue