Documentation
¶
Overview ¶
Package syncutil provides synchronization primitives.
Values containing the types defined in this package should not be copied.
Index ¶
- type Map
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Delete(k K)
- func (m *Map[K, V]) Iter() iter.Seq2[K, V]
- func (m *Map[K, V]) Load(k K) (v V, ok bool)
- func (m *Map[K, V]) Make()
- func (m *Map[K, V]) MakeSize(n int)
- func (m *Map[K, V]) MarshalJSON() ([]byte, error)
- func (m *Map[K, V]) Store(k K, v V)
- func (m *Map[K, V]) Swap(k K, v V) (old V, ok bool)
- func (m *Map[K, V]) UnmarshalJSON(b []byte) error
- type Once
- type OnceValue
- type OnceValues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶ added in v0.0.15
type Map[K comparable, V any] struct { sync.Mutex // contains filtered or unexported fields }
Map is a wrapper around a map[K]V that is safe for concurrent use by multiple goroutines.
func (*Map[K, V]) Clear ¶ added in v0.0.15
func (m *Map[K, V]) Clear()
Clear deletes all the entries, resulting in an empty Map.
func (*Map[K, V]) Delete ¶ added in v0.0.15
func (m *Map[K, V]) Delete(k K)
Delete deletes the value for a key.
func (*Map[K, V]) Iter ¶ added in v0.0.15
Iter locks m and returns an iterator over entries of m. Once iteration is complete, m will be unlocked.
func (*Map[K, V]) Load ¶ added in v0.0.15
Load returns the value stored in the map for a key, or the zero value of V if no value is present. The ok result indicates whether value was found in the map.
func (*Map[K, V]) Make ¶ added in v0.0.15
func (m *Map[K, V]) Make()
Make is the concurrency-safe equivalent of make(map[K]V)
func (*Map[K, V]) MakeSize ¶ added in v0.0.15
MakeSize is the concurrency-safe equivalent of make(map[K]V, n)
func (*Map[K, V]) MarshalJSON ¶ added in v0.0.15
func (*Map[K, V]) Store ¶ added in v0.0.15
func (m *Map[K, V]) Store(k K, v V)
Store sets the value for a key.
func (*Map[K, V]) Swap ¶ added in v0.0.15
Swap swaps the value for a key and returns the previous value if any. The loaded result reports whether the key was present.
func (*Map[K, V]) UnmarshalJSON ¶ added in v0.0.15
type Once ¶
type Once struct {
// contains filtered or unexported fields
}
Once is equivalent to sync.Once with the ability to be reset.
type OnceValue ¶ added in v0.0.15
OnceValue is the struct equivalent of sync.OnceValue with the ability to be reset.
type OnceValues ¶ added in v0.0.15
OnceValues is the struct equivalent of sync.OnceValues with the ability to be reset.
func (*OnceValues[T1, T2]) Do ¶ added in v0.0.15
func (o *OnceValues[T1, T2]) Do(f func() (T1, T2)) (T1, T2)