sync

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2023 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map[K any, V any] struct {
	// contains filtered or unexported fields
}

Map is a generic version of sync.Map More info sees https://pkg.go.dev/sync#Map

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(key K)

Delete deletes the value for a key.

func (*Map[K, V]) Load

func (m *Map[K, V]) Load(key K) (value V, ok bool)

Load returns the value stored in the map for a key, or zero value of T if no value is present. The ok result indicates whether value was found in the map.

func (*Map[K, V]) LoadAndDelete

func (m *Map[K, V]) LoadAndDelete(key K) (value V, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.

func (*Map[K, V]) LoadOrStore

func (m *Map[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(f func(key K, value V) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration. More info sees https://pkg.go.dev/sync#Map.Range

func (*Map[K, V]) Store

func (m *Map[K, V]) Store(key K, value V)

Store sets the value for a key.

type Mutex

type Mutex = ss.Mutex

Mutex is reexport sync.Mutex for easy use. More info sees https://pkg.go.dev/sync#Mutex

type Pool

type Pool[T any] struct {
	New func() T
	// contains filtered or unexported fields
}

Pool is a generic version of sync.Pool More info sees https://pkg.go.dev/sync#Pool

func (*Pool[T]) Get

func (p *Pool[T]) Get() (T, bool)

Get selects an arbitrary item from the pool, removes it from the pool, and returns it to the caller. The ok result indicates whether value was found in the pool. It returns (zero value of T, false) if there has nothing in the pool.

func (*Pool[T]) MustGet

func (p *Pool[T]) MustGet() T

Get selects an arbitrary item from the pool, removes it from the pool, and returns it to the caller. It will call Pool.New to create value if there has nothing in the pool. It will panic if Pool.New is nil.

func (*Pool[T]) Put

func (p *Pool[T]) Put(v T)

Put adds v to the pool.

type RWMutex

type RWMutex = ss.RWMutex

RWMutex is reexport sync.RWMutex for easy use. More info sees https://pkg.go.dev/sync#RWMutex

type Value

type Value[T any] struct {
	// contains filtered or unexported fields
}

Value is a generic version of atomic.Value More info sees https://pkg.go.dev/sync/atomic#Value

func (*Value[T]) CompareAndSwap

func (v *Value[T]) CompareAndSwap(old T, new T) (swapped bool)

CompareAndSwap executes the compare-and-swap operation for the Value[T]. It will panic if T is not an comparable type.

func (*Value[T]) Load

func (v *Value[T]) Load() (val T, ok bool)

Load returns the value set by the most recent Store. It returns (zero value of T, false) if there has been no call to Store for this Value.

func (*Value[T]) MustLoad

func (v *Value[T]) MustLoad() T

Load returns the value set by the most recent Store. It will panic if there has been no call to Store for this Value.

func (*Value[T]) Store

func (v *Value[T]) Store(val T)

Store sets the value of the Value[T] to x.

func (*Value[T]) Swap

func (v *Value[T]) Swap(new T) (val T, ok bool)

Swap stores new into Value[T] and returns the previous value. It returns (zero value of T, false) if the Value[T] is empty.

type WaitGroup

type WaitGroup = ss.WaitGroup

WaitGroup is reexport sync.WaitGroup for easy use. More info sees https://pkg.go.dev/sync#WaitGroup

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL