mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-13 22:47:30 +00:00
syncs: add map.Clear() method
Updates https://github.com/tailscale/corp/issues/13979 Signed-off-by: Denton Gentry <dgentry@tailscale.com>
This commit is contained in:

committed by
Denton Gentry

parent
239ad57446
commit
7e15c78a5a
@@ -9,6 +9,7 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
"tailscale.com/util/mak"
|
||||
)
|
||||
|
||||
@@ -227,6 +228,13 @@ func (m *Map[K, V]) Len() int {
|
||||
return len(m.m)
|
||||
}
|
||||
|
||||
// Clear removes all entries from the map.
|
||||
func (m *Map[K, V]) Clear() {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
maps.Clear(m.m)
|
||||
}
|
||||
|
||||
// WaitGroup is identical to [sync.WaitGroup],
|
||||
// but provides a Go method to start a goroutine.
|
||||
type WaitGroup struct{ sync.WaitGroup }
|
||||
|
Reference in New Issue
Block a user