sync/waitgroup: initial sync.WaitGroup wrapper with context support #319
@ -57,16 +57,9 @@ func (g *WaitGroup) WaitContext(ctx context.Context) {
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
g.drain.Swap(true)
|
||||
for g.c.Load() > 0 {
|
||||
select {
|
||||
case <-done:
|
||||
g.drain.Swap(false)
|
||||
g.wg.Add(-int(g.c.Load()))
|
||||
<-done
|
||||
return
|
||||
default:
|
||||
g.wg.Done()
|
||||
}
|
||||
}
|
||||
case <-done:
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user