sync/waitgroup: initial sync.WaitGroup wrapper with context support #319

Merged
vtolstov merged 7 commits from waitgroup into master 2024-03-09 23:35:14 +03:00
Showing only changes of commit a39a2f398a - Show all commits

View File

@ -57,16 +57,9 @@ func (g *WaitGroup) WaitContext(ctx context.Context) {
select { select {
case <-ctx.Done(): case <-ctx.Done():
g.drain.Swap(true) g.wg.Add(-int(g.c.Load()))
for g.c.Load() > 0 { <-done
select {
case <-done:
g.drain.Swap(false)
return return
default:
g.wg.Done()
}
}
case <-done: case <-done:
return return
} }