mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-23 09:06:24 +00:00
syncs: delete WaitGroup and use sync.WaitGroup.Go in Go 1.25
Our own WaitGroup wrapper type was a prototype implementation for the Go method on the standard sync.WaitGroup type. Now that there is first-class support for Go, we should migrate over to using it and delete syncs.WaitGroup. Updates #cleanup Updates tailscale/tailscale#16330 Change-Id: Ib52b10f9847341ce29b4ca0da927dc9321691235 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
f5d3c59a92
commit
3aea0e095a
@@ -402,19 +402,3 @@ func (m *Map[K, V]) Swap(key K, value V) (oldValue V) {
|
||||
mak.Set(&m.m, key, value)
|
||||
return oldValue
|
||||
}
|
||||
|
||||
// WaitGroup is identical to [sync.WaitGroup],
|
||||
// but provides a Go method to start a goroutine.
|
||||
type WaitGroup struct{ sync.WaitGroup }
|
||||
|
||||
// Go calls the given function in a new goroutine.
|
||||
// It automatically increments the counter before execution and
|
||||
// automatically decrements the counter after execution.
|
||||
// It must not be called concurrently with Wait.
|
||||
func (wg *WaitGroup) Go(f func()) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
f()
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user