mirror of https://github.com/panjf2000/ants.git
Merge branch 'master' into develop
This commit is contained in:
commit
e8b1147e29
7
pool.go
7
pool.go
|
@ -52,7 +52,10 @@ type Pool struct {
|
|||
|
||||
// lock for synchronous operation.
|
||||
lock sync.Mutex
|
||||
|
||||
// cond for waiting idle worker
|
||||
cond *sync.Cond
|
||||
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
|
@ -196,10 +199,10 @@ func (p *Pool) getWorker() *Worker {
|
|||
}
|
||||
|
||||
if waiting {
|
||||
for{
|
||||
for {
|
||||
p.cond.Wait()
|
||||
l := len(p.workers) - 1
|
||||
if l < 0{
|
||||
if l < 0 {
|
||||
continue
|
||||
}
|
||||
w = p.workers[l]
|
||||
|
|
|
@ -50,7 +50,10 @@ type PoolWithFunc struct {
|
|||
|
||||
// lock for synchronous operation.
|
||||
lock sync.Mutex
|
||||
|
||||
// cond for waiting idle worker
|
||||
cond *sync.Cond
|
||||
|
||||
// pf is the function for processing tasks.
|
||||
poolFunc pf
|
||||
|
||||
|
@ -198,10 +201,10 @@ func (p *PoolWithFunc) getWorker() *WorkerWithFunc {
|
|||
}
|
||||
|
||||
if waiting {
|
||||
for{
|
||||
for {
|
||||
p.cond.Wait()
|
||||
l := len(p.workers) - 1
|
||||
if l < 0{
|
||||
if l < 0 {
|
||||
continue
|
||||
}
|
||||
w = p.workers[l]
|
||||
|
|
Loading…
Reference in New Issue