File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -37,11 +37,7 @@ func (wg *waitGroup) Add(delta int) {
37
37
panic ("WaitGroup misuse: Add called concurrently with Wait" )
38
38
}
39
39
40
- if wg .n > 0 || ! wg .waiting {
41
- return
42
- }
43
-
44
- if wg .n == 0 {
40
+ if delta < 0 && wg .n == 0 {
45
41
wg .f .Set (struct {}{}, nil )
46
42
}
47
43
}
Original file line number Diff line number Diff line change @@ -14,6 +14,25 @@ func Test_WaitGroup_PanicsForInvalidCounters(t *testing.T) {
14
14
})
15
15
}
16
16
17
+ func Test_WaitGroup_WaitAfterdone (t * testing.T ) {
18
+ s := NewScheduler ()
19
+ ctx := Background ()
20
+
21
+ wg := NewWaitGroup ()
22
+ wg .Add (2 )
23
+ wg .Done ()
24
+ wg .Done ()
25
+
26
+ s .NewCoroutine (ctx , func (ctx Context ) error {
27
+ wg .Wait (ctx )
28
+
29
+ return nil
30
+ })
31
+
32
+ s .Execute ()
33
+ require .Equal (t , 0 , s .RunningCoroutines ())
34
+ }
35
+
17
36
func Test_WaitGroup_Blocks (t * testing.T ) {
18
37
s := NewScheduler ()
19
38
ctx := Background ()
You can’t perform that action at this time.
0 commit comments