Documentation ¶
Overview ¶
Package atomicptrmap instantiates generic_atomicptrmap for testing.
Package atomicptrmap doesn't exist. This file must be instantiated using the go_template_instance rule in tools/go_generics/defs.bzl.
Index ¶
- Constants
- type AtomicPtrMap
- func (m *AtomicPtrMap) CompareAndSwap(key Key, oldVal, newVal *Value) *Value
- func (m *AtomicPtrMap) Load(key Key) *Value
- func (m *AtomicPtrMap) Range(f func(key Key, val *Value) bool)
- func (m *AtomicPtrMap) RangeRepeatable(f func(key Key, val *Value) bool)
- func (m *AtomicPtrMap) Store(key Key, val *Value)
- func (m *AtomicPtrMap) Swap(key Key, val *Value) *Value
- type Hasher
- type Key
- type Value
Constants ¶
const ( // ShardOrder is an optional parameter specifying the base-2 log of the // number of shards per AtomicPtrMap. Higher values of ShardOrder reduce // unnecessary synchronization between unrelated concurrent operations, // improving performance for write-heavy workloads, but increase memory // usage for small maps. ShardOrder = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtomicPtrMap ¶
type AtomicPtrMap struct {
// contains filtered or unexported fields
}
An AtomicPtrMap maps Keys to non-nil pointers to Values. AtomicPtrMap are safe for concurrent use from multiple goroutines without additional synchronization.
The zero value of AtomicPtrMap is empty (maps all Keys to nil) and ready for use. AtomicPtrMaps must not be copied after first use.
sync.Map may be faster than AtomicPtrMap if most operations on the map are concurrent writes to a fixed set of keys. AtomicPtrMap is usually faster in other circumstances.
func (*AtomicPtrMap) CompareAndSwap ¶
func (m *AtomicPtrMap) CompareAndSwap(key Key, oldVal, newVal *Value) *Value
CompareAndSwap checks that the Value stored for key is oldVal; if it is, it stores the Value newVal for key. CompareAndSwap returns the previous Value stored for key, whether or not it stores newVal.
func (*AtomicPtrMap) Load ¶
func (m *AtomicPtrMap) Load(key Key) *Value
Load returns the Value stored in m for key.
func (*AtomicPtrMap) Range ¶
func (m *AtomicPtrMap) Range(f func(key Key, val *Value) bool)
Range invokes f on each Key-Value pair stored in m. If any call to f returns false, Range stops iteration and returns.
Range does not necessarily correspond to any consistent snapshot of the Map's contents: no Key will be visited more than once, but if the Value for any Key is stored or deleted concurrently, Range may reflect any mapping for that Key from any point during the Range call.
f must not call other methods on m.
func (*AtomicPtrMap) RangeRepeatable ¶
func (m *AtomicPtrMap) RangeRepeatable(f func(key Key, val *Value) bool)
RangeRepeatable is like Range, but:
RangeRepeatable may visit the same Key multiple times in the presence of concurrent mutators, possibly passing different Values to f in different calls.
It is safe for f to call other methods on m.
func (*AtomicPtrMap) Store ¶
func (m *AtomicPtrMap) Store(key Key, val *Value)
Store stores the Value val for key.