xsync

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicFloat64

type AtomicFloat64 atomic.Uint64

AtomicFloat64 is an atomic float64 variable.

func (*AtomicFloat64) Add

func (x *AtomicFloat64) Add(delta float64) (new float64)

Add atomically adds delta to this value and returns the result.

This will not compile down to a single instruction, because no one provides that. Instead, this just does a CAS loop.

func (*AtomicFloat64) BitwiseCompareAndSwap

func (x *AtomicFloat64) BitwiseCompareAndSwap(old, new float64) (swapped bool)

Swap atomically stores the given float64 if x currently holds a float with the same bit-pattern as val.

That is to say, this does *not* perform a floating-point comparison!

func (*AtomicFloat64) Load

func (x *AtomicFloat64) Load() float64

Load atomically loads the wrapped float64.

func (*AtomicFloat64) Store

func (x *AtomicFloat64) Store(val float64)

Store atomically stores the passed float64.

func (*AtomicFloat64) Swap

func (x *AtomicFloat64) Swap(val float64) (old float64)

Swap atomically stores the given float64 and returns the old value.

type Map

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

Map is a strongly-typed wrapper over sync.Map.

func (*Map[K, V]) All

func (m *Map[K, V]) All() iter.Seq2[K, V]

All returns an iterator over the values in this map, using sync.Map.Range.

func (*Map[K, V]) Load

func (m *Map[K, V]) Load(k K) (V, bool)

Load forwards to sync.Map.Load.

func (*Map[K, V]) LoadOrStore

func (m *Map[K, V]) LoadOrStore(k K, make func() V) (actual V, loaded bool)

LoadOrStore loads a value if its present, or constructs it with make and inserts it.

There is a possibility that make is called, but the return value is not inserted.

func (*Map[K, V]) Store

func (m *Map[K, V]) Store(k K, v V)

Store forwards to sync.Map.Store.

type Pool

type Pool[T any] struct {
	New   func() *T // Called to construct new values.
	Reset func(*T)  // Called to reset values before re-use.
	// contains filtered or unexported fields
}

Pool is like sync.Pool, but strongly typed to make the interface a bit less messy.

func (*Pool[T]) Get

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

Get returns a cached value of type T.

func (*Pool[T]) Put

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

Put returns a cached value of type T.

type Set

type Set[K comparable] struct {
	// contains filtered or unexported fields
}

Set is a strongly-typed wrapper over sync.Map, used as a set.

func (*Set[K]) All

func (s *Set[K]) All() iter.Seq[K]

All returns an iterator over the values in this set, using sync.Map.Range.

func (*Set[K]) Load

func (s *Set[K]) Load(k K) bool

Load forwards to sync.Map.Load.

func (*Set[K]) Store

func (s *Set[K]) Store(k K)

Store forwards to sync.Map.Store.

Jump to

Keyboard shortcuts

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