Documentation
¶
Index ¶
- Variables
- func OnceValue[T any](f func() T) func() T
- func OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2)
- func Sleep(ctx context.Context, duration time.Duration) error
- type Cond
- 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]) Load(key K) (V, bool)
- func (m *Map[K, V]) LoadOrStore(key K, store V) (V, bool)
- func (m *Map[K, V]) LoadOrStoreFunc(key K, generator func(key K) (value V)) (value V)
- 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 Mutex
- type Once
- type Pool
- type RWMutex
- type WaitGroup
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NewCond = sync.NewCond OnceFunc = sync.OnceFunc )
Functions
Functions ¶
func OnceValues ¶
func OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2)
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a thread-safe generic map implementation on top of sync.Map
func NewMap ¶
func NewMap[K comparable, V any]() *Map[K, V]
func (*Map[K, V]) LoadOrStore ¶
func (*Map[K, V]) LoadOrStoreFunc ¶
func (m *Map[K, V]) LoadOrStoreFunc(key K, generator func(key K) (value V)) (value V)
LoadOrStoreFunc loads the value for the given key, if it exists. If the key does not exist, it calls the generator function to create the value and stores it in the map. The generator function is guaranteed to be called synchronously and only once for the same key.
Click to show internal directories.
Click to hide internal directories.