Documentation
¶
Index ¶
- func InitPtrMaybe[K comparable, V any](m *RWMap[K, *V], key K)
- type RWMap
- func (m *RWMap[K, V]) Clear()
- func (m *RWMap[K, V]) Default(key K, fn func() V) (changed bool)
- func (m *RWMap[K, V]) Delete(key K)
- func (m *RWMap[K, V]) Get(key K) (value V, ok bool)
- func (m *RWMap[K, V]) Has(key K) (ok bool)
- func (m *RWMap[K, V]) Len() int
- func (m *RWMap[K, V]) Range(f func(key K, value V) bool)
- func (m *RWMap[K, V]) Set(key K, value V)
- type RWValue
- type Watch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitPtrMaybe ¶ added in v1.11.0
func InitPtrMaybe[K comparable, V any](m *RWMap[K, *V], key K)
InitPtrMaybe sets a pointer-value in the map, if it's not set yet, to a new object.
Types ¶
type RWMap ¶
type RWMap[K comparable, V any] struct { // contains filtered or unexported fields }
RWMap is a simple wrapper around a map, with global Read-Write protection. For many concurrent reads/writes a sync.Map may be more performant, although it does not utilize Go generics. The RWMap does not have to be initialized, it is immediately ready for reads/writes.
func (*RWMap[K, V]) Clear ¶
func (m *RWMap[K, V]) Clear()
Clear removes all key-value pairs from the map.
func (*RWMap[K, V]) Default ¶ added in v1.11.0
Default creates a value at the given key, if the key is not set yet.
type RWValue ¶
RWValue is a simple container struct, to deconflict reads/writes of the value, without locking up a bigger structure in the caller. It exposes the underlying RWLock and Value for direct access where needed.
type Watch ¶ added in v1.11.0
type Watch[E any] struct { // contains filtered or unexported fields }
Watch makes a value watch-able: every change will be notified to those watching.