forked from mirror/ants
Fix a issue in testing nonblocking pool
This commit is contained in:
parent
b0ec5102cc
commit
0a946593e2
|
@ -421,8 +421,10 @@ func TestNonblockingSubmit(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ch := make(chan struct{})
|
ch := make(chan struct{})
|
||||||
|
ch1 := make(chan struct{})
|
||||||
f := func() {
|
f := func() {
|
||||||
<-ch
|
<-ch
|
||||||
|
close(ch1)
|
||||||
}
|
}
|
||||||
// p is full now.
|
// p is full now.
|
||||||
if err := p.Submit(f); err != nil {
|
if err := p.Submit(f); err != nil {
|
||||||
|
@ -433,7 +435,7 @@ func TestNonblockingSubmit(t *testing.T) {
|
||||||
}
|
}
|
||||||
// interrupt f to get an available worker
|
// interrupt f to get an available worker
|
||||||
close(ch)
|
close(ch)
|
||||||
time.Sleep(1 * time.Second)
|
<-ch1
|
||||||
if err := p.Submit(demoFunc); err != nil {
|
if err := p.Submit(demoFunc); err != nil {
|
||||||
t.Fatalf("nonblocking submit when pool is not full shouldn't return error")
|
t.Fatalf("nonblocking submit when pool is not full shouldn't return error")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue