Skip to content
Merged
6 changes: 3 additions & 3 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (p *Pool) addWaiting(delta int) {
}

// retrieveWorker returns an available worker to run the tasks.
func (p *Pool) retrieveWorker() (w worker) {
func (p *Pool) retrieveWorker() (w worker, err error) {
p.lock.Lock()

retry:
Expand All @@ -351,7 +351,7 @@ retry:
// Bail out early if it's in nonblocking mode or the number of pending callers reaches the maximum limit value.
if p.options.Nonblocking || (p.options.MaxBlockingTasks != 0 && p.Waiting() >= p.options.MaxBlockingTasks) {
p.lock.Unlock()
return
return nil, ErrPoolOverload
}

// Otherwise, we'll have to keep them blocked and wait for at least one worker to be put back into pool.
Expand All @@ -361,7 +361,7 @@ retry:

if p.IsClosed() {
p.lock.Unlock()
return
return nil, ErrPoolClosed
}

goto retry
Expand Down
6 changes: 3 additions & 3 deletions pool_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (p *PoolWithFunc) addWaiting(delta int) {
}

// retrieveWorker returns an available worker to run the tasks.
func (p *PoolWithFunc) retrieveWorker() (w worker) {
func (p *PoolWithFunc) retrieveWorker() (w worker, err error) {
p.lock.Lock()

retry:
Expand All @@ -357,7 +357,7 @@ retry:
// Bail out early if it's in nonblocking mode or the number of pending callers reaches the maximum limit value.
if p.options.Nonblocking || (p.options.MaxBlockingTasks != 0 && p.Waiting() >= p.options.MaxBlockingTasks) {
p.lock.Unlock()
return
return nil, ErrPoolOverload
}

// Otherwise, we'll have to keep them blocked and wait for at least one worker to be put back into pool.
Expand All @@ -367,7 +367,7 @@ retry:

if p.IsClosed() {
p.lock.Unlock()
return
return nil, ErrPoolClosed
}

goto retry
Expand Down
⌂ 换网址