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 1759bec5a9 - Show all commits

View File

@ -7,9 +7,9 @@ import (
) )
type WaitGroup struct { type WaitGroup struct {
mu sync.Mutex
wg *sync.WaitGroup wg *sync.WaitGroup
c *atomic.Int64 c *atomic.Int64
mu sync.Mutex
} }
func WrapWaitGroup(wg *sync.WaitGroup) *WaitGroup { func WrapWaitGroup(wg *sync.WaitGroup) *WaitGroup {
@ -22,11 +22,7 @@ func WrapWaitGroup(wg *sync.WaitGroup) *WaitGroup {
func NewWaitGroup() *WaitGroup { func NewWaitGroup() *WaitGroup {
var wg sync.WaitGroup var wg sync.WaitGroup
g := &WaitGroup{ return WrapWaitGroup(&wg)
wg: &wg,
c: &(atomic.Int64{}),
}
return g
} }
func (g *WaitGroup) Add(n int) { func (g *WaitGroup) Add(n int) {