Documentation
¶
Overview ¶
Package generic_sync 提供泛型同步原语
Index ¶
- type Lazy
- type Map
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Delete(key K)
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Load(key K) (V, bool)
- func (m *Map[K, V]) LoadAndDelete(key K) (V, bool)
- func (m *Map[K, V]) LoadOrStore(key K, value V) (V, bool)
- func (m *Map[K, V]) Range(f func(key K, value V) bool)
- func (m *Map[K, V]) Store(key K, value V)
- func (m *Map[K, V]) Values() []V
- type Once
- type Pool
- type RWMutexMap
- func (m *RWMutexMap[K, V]) Compute(key K, f func(V, bool) V) V
- func (m *RWMutexMap[K, V]) Delete(key K)
- func (m *RWMutexMap[K, V]) ForEach(f func(K, V))
- func (m *RWMutexMap[K, V]) Get(key K) (V, bool)
- func (m *RWMutexMap[K, V]) GetOrSet(key K, value V) (V, bool)
- func (m *RWMutexMap[K, V]) Set(key K, value V)
- func (m *RWMutexMap[K, V]) SetIfAbsent(key K, value V) bool
- func (m *RWMutexMap[K, V]) Size() int
- type Value
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 是一个泛型并发安全的 map
func (*Map[K, V]) LoadAndDelete ¶
LoadAndDelete 加载并删除值
func (*Map[K, V]) LoadOrStore ¶
LoadOrStore 加载或存储值
type Once ¶
type Once[T any] struct { // contains filtered or unexported fields }
Once 是一个泛型的 sync.Once,返回值
type RWMutexMap ¶
type RWMutexMap[K comparable, V any] struct { // contains filtered or unexported fields }
RWMutexMap 是带读写锁的泛型 map
func NewRWMutexMap ¶
func NewRWMutexMap[K comparable, V any]() *RWMutexMap[K, V]
NewRWMutexMap 创建 RWMutexMap
func (*RWMutexMap[K, V]) Compute ¶
func (m *RWMutexMap[K, V]) Compute(key K, f func(V, bool) V) V
Compute 计算并更新值
func (*RWMutexMap[K, V]) GetOrSet ¶
func (m *RWMutexMap[K, V]) GetOrSet(key K, value V) (V, bool)
GetOrSet 获取或设置值
func (*RWMutexMap[K, V]) SetIfAbsent ¶
func (m *RWMutexMap[K, V]) SetIfAbsent(key K, value V) bool
SetIfAbsent 如果不存在则设置
Click to show internal directories.
Click to hide internal directories.