Documentation ¶
Overview ¶
Package syncmap provides a map that is safe for concurrent use. It is similar to sync.Map, but is simpler, and gives a consistent state for range loops.
Index ¶
- type Map
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Delete(key K) bool
- func (m *Map[K, V]) Exclusive(f func(map[K]V))
- func (m *Map[K, V]) ExclusiveRead(f func(map[K]V))
- func (m *Map[K, V]) Extract(key K) (value V, ok bool)
- func (m *Map[K, V]) Get(key K) (value V, ok bool)
- func (m *Map[K, V]) Set(key K, value V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a map that is safe for concurrent use. It is similar to sync.Map, but is simpler, and gives a consistent state for range loops. It takes two generic types, K (key) and V (value). K must be comparable, and V can be any type.
func (*Map[K, V]) Exclusive ¶
func (m *Map[K, V]) Exclusive(f func(map[K]V))
Exclusive calls a callback with exclusive access to the map. Modifications to the map will be kept.
func (*Map[K, V]) ExclusiveRead ¶
func (m *Map[K, V]) ExclusiveRead(f func(map[K]V))
ExclusiveRead calls a callback with exclusive access to the map. It is not safe to modify the map.
func (*Map[K, V]) Extract ¶ added in v0.9.0
Extract removes and returns the key's value, and whether it was found.