File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ func (t *poolExecutor) Submit(f func(), ef func(error)) {
134134 stack := debug .Stack ()
135135 buf .Write (stack )
136136 err := fmt .Errorf ("gp: panic recovered: %s \n %s" , err , buf .String ())
137- if ef = = nil {
137+ if ef ! = nil {
138138 ef (err )
139139 } else {
140140 panic (err )
@@ -160,7 +160,7 @@ func (t *waitPoolExecutor) Submit(f func(), ef func(error)) {
160160 stack := debug .Stack ()
161161 buf .Write (stack )
162162 err := fmt .Errorf ("gp: panic recovered: %s \n %s" , err , buf .String ())
163- if ef = = nil {
163+ if ef ! = nil {
164164 ef (err )
165165 } else {
166166 panic (err )
Original file line number Diff line number Diff line change @@ -7,23 +7,31 @@ import (
77)
88
99func TestPG (t * testing.T ) {
10- Go (func () {
10+ pool := NewWaitPool (2 )
11+ pool .Submit (func () {
1112 xconsole .Red ("test1" )
1213 time .Sleep (2 * time .Second )
1314 xconsole .Red ("test1 Ok" )
14- })
15+ }, nil )
1516
16- Go (func () {
17+ pool . Submit (func () {
1718 xconsole .Red ("test2" )
1819 time .Sleep (3 * time .Second )
1920 xconsole .Red ("test2 Ok" )
20- })
21+ }, nil )
2122
22- Go (func () {
23+ pool . Submit (func () {
2324 xconsole .Red ("test3" )
2425 time .Sleep (4 * time .Second )
2526 xconsole .Red ("test3 Ok" )
27+ },nil )
28+
29+ pool .Submit (func () {
30+ time .Sleep (8 * time .Second )
31+ panic ("test4" )
32+ }, func (err error ) {
33+ xconsole .Red (err .Error ())
2634 })
2735
28- Wait ()
36+ pool . Wait ()
2937}
You can’t perform that action at this time.
0 commit comments