File tree 3 files changed +0
-46
lines changed
3 files changed +0
-46
lines changed Original file line number Diff line number Diff line change @@ -24,18 +24,6 @@ func (g *RoutineGroup) Run(fn func()) {
24
24
}()
25
25
}
26
26
27
- // RunSafe runs the given fn in RoutineGroup, and avoid panics.
28
- // Don't reference the variables from outside,
29
- // because outside variables can be changed by other goroutines
30
- func (g * RoutineGroup ) RunSafe (fn func ()) {
31
- g .waitGroup .Add (1 )
32
-
33
- GoSafe (func () {
34
- defer g .waitGroup .Done ()
35
- fn ()
36
- })
37
- }
38
-
39
27
// Wait waits all running functions to be done.
40
28
func (g * RoutineGroup ) Wait () {
41
29
g .waitGroup .Wait ()
Original file line number Diff line number Diff line change 1
1
package stream
2
2
3
3
import (
4
- "io/ioutil"
5
- "log"
6
- "sync"
7
4
"sync/atomic"
8
5
"testing"
9
6
@@ -23,23 +20,3 @@ func TestRoutineGroupRun(t *testing.T) {
23
20
24
21
assert .Equal (t , int32 (3 ), count )
25
22
}
26
-
27
- func TestRoutingGroupRunSafe (t * testing.T ) {
28
- log .SetOutput (ioutil .Discard )
29
-
30
- var count int32
31
- group := NewRoutineGroup ()
32
- var once sync.Once
33
- for i := 0 ; i < 3 ; i ++ {
34
- group .RunSafe (func () {
35
- once .Do (func () {
36
- panic ("" )
37
- })
38
- atomic .AddInt32 (& count , 1 )
39
- })
40
- }
41
-
42
- group .Wait ()
43
-
44
- assert .Equal (t , int32 (2 ), count )
45
- }
Original file line number Diff line number Diff line change @@ -262,17 +262,6 @@ func TestMap(t *testing.T) {
262
262
},
263
263
expect : 10 ,
264
264
},
265
- {
266
- name : "mapper with panic" ,
267
- mapper : func (item interface {}) interface {} {
268
- v := item .(int )
269
- if v % 2 == 0 {
270
- panic (v )
271
- }
272
- return v * v
273
- },
274
- expect : 10 ,
275
- },
276
265
}
277
266
278
267
// Map(...) works even WithWorkers(0)
You can’t perform that action at this time.
0 commit comments