Documentation
¶
Overview ¶
Package atomix provides atomic primitives with explicit memory ordering.
Architecture ¶
atomix is a foundation layer with no external dependencies. It provides atomic operations for the I/O stack, used by higher-level modules like uring and sox.
Memory Ordering ¶
The package exposes four memory orderings:
- Relaxed: Only atomicity guaranteed; no ordering constraints
- Acquire: Subsequent operations cannot reorder before the load
- Release: Prior operations cannot reorder after the store
- AcqRel: Acquire + Release; for read-modify-write operations
Unlike sync/atomic which provides sequential consistency, this package allows choosing the minimal ordering required for weakly-ordered architectures (ARM, RISC-V).
Two APIs ¶
Type-based API for embedding in structs:
var counter atomix.Int64 counter.Store(0) val := counter.Add(1) // AcqRel ordering (safe default) val = counter.AddRelaxed(1) // Explicit relaxed ordering
Pointer-based API for raw memory (shared memory, io_uring):
var flags int32 atomix.Release.StoreInt32(&flags, 1) val := atomix.Acquire.LoadInt32(&flags) atomix.Relaxed.CompareAndSwapInt32(&flags, 0, 1)
The pointer-based API uses MemoryOrder constants as method receivers. Unknown orderings fall back to safe defaults (Load→Acquire, Store→Release, RMW→AcqRel).
Types ¶
Core atomic types:
- Bool: Atomic boolean (backed by uint32)
- Int32, Uint32: 32-bit integers
- Int64, Uint64: 64-bit integers
- Uintptr: Pointer-sized integer
- Pointer: Generic atomic pointer
- Int128, Uint128: 128-bit integers (requires 16-byte alignment)
Cache-line padded variants prevent false sharing:
- Int32Padded, Uint32Padded, Int64Padded, Uint64Padded
- UintptrPadded, BoolPadded, Int128Padded, Uint128Padded
All types are safe for concurrent use. The zero value is valid (0 or nil).
Operations ¶
All types support Load, Store, Swap, CompareAndSwap, CompareExchange, Add, Sub, And, Or, Xor, Max, Min, Inc, Dec with explicit ordering suffixes.
Default methods use: Load=Relaxed, Store=Relaxed, RMW=AcqRel. Note: sync/atomic uses acquire for Load and release for Store. Use LoadAcquire/StoreRelease for sync/atomic-equivalent ordering.
Return value semantics match sync/atomic:
- Add/Sub/Inc/Dec return the NEW value (after the operation)
- Swap/And/Or/Xor/Max/Min return the OLD value (before the operation)
Platform Support ¶
Primary (native atomic instructions):
- amd64: LOCK-prefixed instructions; TSO provides acquire/release
- arm64: LSE atomics (ARMv8.1+) for 32/64-bit; LL/SC or CASP for 128-bit
Secondary (native with limitations):
- riscv64: AMO instructions with .aq/.rl suffixes
- loong64: AM*_DB instructions
Fallback: Other architectures use sync/atomic (over-synchronized).
ARM64 128-bit Build Options ¶
ARM64 128-bit atomics support two implementations via build tags:
- Default (!lse2): LL/SC using LDXP/STXP instructions
- -tags=lse2: CASP instruction (LSE2)
LL/SC has lower microarchitectural overhead than CASP in uncontended cases. Use -tags=lse2 for ARMv8.4+ hardware with high-contention workloads.
128-bit Atomics ¶
Int128 and Uint128 require 16-byte alignment. Use PlaceAlignedInt128 or PlaceAlignedUint128 to ensure proper alignment.
True 128-bit atomicity is only available on:
- amd64: LOCK CMPXCHG16B
- arm64: LDXP/STXP (default) or CASP (-tags=lse2)
Other architectures provide mutual exclusion but may exhibit torn reads.
Placement Helpers ¶
For embedding atomics in shared memory or custom allocators:
- CanPlaceAligned4, CanPlaceAligned8, CanPlaceAligned16
- PlaceAlignedInt32, PlaceAlignedInt64, PlaceAlignedUint128, etc.
- Allocator: Sequential allocator for building atomic structures
Index ¶
- Constants
- func BarrierAcqRel()
- func BarrierAcquire()
- func BarrierRelease()
- func CanPlaceAligned16(p []byte, off int) bool
- func CanPlaceAligned4(p []byte, off int) bool
- func CanPlaceAligned8(p []byte, off int) bool
- func CanPlaceCacheAligned(p []byte, off, size int) bool
- type Allocator
- func (a *Allocator) Align(alignment int)
- func (a *Allocator) Bool() *Bool
- func (a *Allocator) CacheAlignedBool() *BoolPadded
- func (a *Allocator) CacheAlignedInt128() *Int128Padded
- func (a *Allocator) CacheAlignedInt32() *Int32Padded
- func (a *Allocator) CacheAlignedInt64() *Int64Padded
- func (a *Allocator) CacheAlignedUint128() *Uint128Padded
- func (a *Allocator) CacheAlignedUint32() *Uint32Padded
- func (a *Allocator) CacheAlignedUint64() *Uint64Padded
- func (a *Allocator) CacheAlignedUintptr() *UintptrPadded
- func (a *Allocator) Int128() *Int128
- func (a *Allocator) Int32() *Int32
- func (a *Allocator) Int64() *Int64
- func (a *Allocator) Offset() int
- func (a *Allocator) Remaining() int
- func (a *Allocator) Reset()
- func (a *Allocator) Skip(n int)
- func (a *Allocator) Uint128() *Uint128
- func (a *Allocator) Uint32() *Uint32
- func (a *Allocator) Uint64() *Uint64
- func (a *Allocator) Uintptr() *Uintptr
- type Bool
- func (a *Bool) CompareAndSwap(old, new bool) bool
- func (a *Bool) CompareAndSwapAcqRel(old, new bool) bool
- func (a *Bool) CompareAndSwapAcquire(old, new bool) bool
- func (a *Bool) CompareAndSwapRelaxed(old, new bool) bool
- func (a *Bool) CompareAndSwapRelease(old, new bool) bool
- func (a *Bool) Load() bool
- func (a *Bool) LoadAcquire() bool
- func (a *Bool) LoadRelaxed() bool
- func (a *Bool) Store(val bool)
- func (a *Bool) StoreRelaxed(val bool)
- func (a *Bool) StoreRelease(val bool)
- func (a *Bool) Swap(new bool) bool
- func (a *Bool) SwapAcqRel(new bool) bool
- func (a *Bool) SwapAcquire(new bool) bool
- func (a *Bool) SwapRelaxed(new bool) bool
- func (a *Bool) SwapRelease(new bool) bool
- type BoolPadded
- type Int128
- func (a *Int128) Add(deltaLo, deltaHi int64) (lo, hi int64)
- func (a *Int128) AddRelaxed(deltaLo, deltaHi int64) (lo, hi int64)
- func (a *Int128) CompareAndSwap(oldLo, oldHi, newLo, newHi int64) bool
- func (a *Int128) CompareAndSwapAcqRel(oldLo, oldHi, newLo, newHi int64) bool
- func (a *Int128) CompareAndSwapAcquire(oldLo, oldHi, newLo, newHi int64) bool
- func (a *Int128) CompareAndSwapRelaxed(oldLo, oldHi, newLo, newHi int64) bool
- func (a *Int128) CompareAndSwapRelease(oldLo, oldHi, newLo, newHi int64) bool
- func (a *Int128) CompareExchange(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)
- func (a *Int128) CompareExchangeAcqRel(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)
- func (a *Int128) CompareExchangeAcquire(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)
- func (a *Int128) CompareExchangeRelaxed(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)
- func (a *Int128) CompareExchangeRelease(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)
- func (a *Int128) Dec() (lo, hi int64)
- func (a *Int128) DecRelaxed() (lo, hi int64)
- func (a *Int128) Equal(lo, hi int64) bool
- func (a *Int128) EqualRelaxed(lo, hi int64) bool
- func (a *Int128) Greater(lo, hi int64) bool
- func (a *Int128) GreaterOrEqual(lo, hi int64) bool
- func (a *Int128) GreaterOrEqualRelaxed(lo, hi int64) bool
- func (a *Int128) GreaterRelaxed(lo, hi int64) bool
- func (a *Int128) Inc() (lo, hi int64)
- func (a *Int128) IncRelaxed() (lo, hi int64)
- func (a *Int128) Less(lo, hi int64) bool
- func (a *Int128) LessOrEqual(lo, hi int64) bool
- func (a *Int128) LessOrEqualRelaxed(lo, hi int64) bool
- func (a *Int128) LessRelaxed(lo, hi int64) bool
- func (a *Int128) Load() (lo, hi int64)
- func (a *Int128) LoadAcquire() (lo, hi int64)
- func (a *Int128) LoadRelaxed() (lo, hi int64)
- func (a *Int128) Store(lo, hi int64)
- func (a *Int128) StoreRelaxed(lo, hi int64)
- func (a *Int128) StoreRelease(lo, hi int64)
- func (a *Int128) Sub(deltaLo, deltaHi int64) (lo, hi int64)
- func (a *Int128) SubRelaxed(deltaLo, deltaHi int64) (lo, hi int64)
- func (a *Int128) Swap(newLo, newHi int64) (oldLo, oldHi int64)
- func (a *Int128) SwapAcqRel(newLo, newHi int64) (oldLo, oldHi int64)
- func (a *Int128) SwapAcquire(newLo, newHi int64) (oldLo, oldHi int64)
- func (a *Int128) SwapRelaxed(newLo, newHi int64) (oldLo, oldHi int64)
- func (a *Int128) SwapRelease(newLo, newHi int64) (oldLo, oldHi int64)
- type Int128Padded
- type Int32
- func (a *Int32) Add(delta int32) int32
- func (a *Int32) AddAcqRel(delta int32) int32
- func (a *Int32) AddAcquire(delta int32) int32
- func (a *Int32) AddRelaxed(delta int32) int32
- func (a *Int32) AddRelease(delta int32) int32
- func (a *Int32) And(mask int32) int32
- func (a *Int32) AndAcqRel(mask int32) int32
- func (a *Int32) AndAcquire(mask int32) int32
- func (a *Int32) AndRelaxed(mask int32) int32
- func (a *Int32) AndRelease(mask int32) int32
- func (a *Int32) CompareAndSwap(old, new int32) bool
- func (a *Int32) CompareAndSwapAcqRel(old, new int32) bool
- func (a *Int32) CompareAndSwapAcquire(old, new int32) bool
- func (a *Int32) CompareAndSwapRelaxed(old, new int32) bool
- func (a *Int32) CompareAndSwapRelease(old, new int32) bool
- func (a *Int32) CompareExchange(old, new int32) int32
- func (a *Int32) CompareExchangeAcqRel(old, new int32) int32
- func (a *Int32) CompareExchangeAcquire(old, new int32) int32
- func (a *Int32) CompareExchangeRelaxed(old, new int32) int32
- func (a *Int32) CompareExchangeRelease(old, new int32) int32
- func (a *Int32) Load() int32
- func (a *Int32) LoadAcquire() int32
- func (a *Int32) LoadRelaxed() int32
- func (a *Int32) Max(val int32) int32
- func (a *Int32) MaxRelaxed(val int32) int32
- func (a *Int32) Min(val int32) int32
- func (a *Int32) MinRelaxed(val int32) int32
- func (a *Int32) Or(mask int32) int32
- func (a *Int32) OrAcqRel(mask int32) int32
- func (a *Int32) OrAcquire(mask int32) int32
- func (a *Int32) OrRelaxed(mask int32) int32
- func (a *Int32) OrRelease(mask int32) int32
- func (a *Int32) Store(val int32)
- func (a *Int32) StoreRelaxed(val int32)
- func (a *Int32) StoreRelease(val int32)
- func (a *Int32) Sub(delta int32) int32
- func (a *Int32) SubAcqRel(delta int32) int32
- func (a *Int32) SubAcquire(delta int32) int32
- func (a *Int32) SubRelaxed(delta int32) int32
- func (a *Int32) SubRelease(delta int32) int32
- func (a *Int32) Swap(new int32) int32
- func (a *Int32) SwapAcqRel(new int32) int32
- func (a *Int32) SwapAcquire(new int32) int32
- func (a *Int32) SwapRelaxed(new int32) int32
- func (a *Int32) SwapRelease(new int32) int32
- func (a *Int32) Xor(mask int32) int32
- func (a *Int32) XorAcqRel(mask int32) int32
- func (a *Int32) XorAcquire(mask int32) int32
- func (a *Int32) XorRelaxed(mask int32) int32
- func (a *Int32) XorRelease(mask int32) int32
- type Int32Padded
- type Int64
- func (a *Int64) Add(delta int64) int64
- func (a *Int64) AddAcqRel(delta int64) int64
- func (a *Int64) AddAcquire(delta int64) int64
- func (a *Int64) AddRelaxed(delta int64) int64
- func (a *Int64) AddRelease(delta int64) int64
- func (a *Int64) And(mask int64) int64
- func (a *Int64) AndAcqRel(mask int64) int64
- func (a *Int64) AndAcquire(mask int64) int64
- func (a *Int64) AndRelaxed(mask int64) int64
- func (a *Int64) AndRelease(mask int64) int64
- func (a *Int64) CompareAndSwap(old, new int64) bool
- func (a *Int64) CompareAndSwapAcqRel(old, new int64) bool
- func (a *Int64) CompareAndSwapAcquire(old, new int64) bool
- func (a *Int64) CompareAndSwapRelaxed(old, new int64) bool
- func (a *Int64) CompareAndSwapRelease(old, new int64) bool
- func (a *Int64) CompareExchange(old, new int64) int64
- func (a *Int64) CompareExchangeAcqRel(old, new int64) int64
- func (a *Int64) CompareExchangeAcquire(old, new int64) int64
- func (a *Int64) CompareExchangeRelaxed(old, new int64) int64
- func (a *Int64) CompareExchangeRelease(old, new int64) int64
- func (a *Int64) Load() int64
- func (a *Int64) LoadAcquire() int64
- func (a *Int64) LoadRelaxed() int64
- func (a *Int64) Max(val int64) int64
- func (a *Int64) MaxRelaxed(val int64) int64
- func (a *Int64) Min(val int64) int64
- func (a *Int64) MinRelaxed(val int64) int64
- func (a *Int64) Or(mask int64) int64
- func (a *Int64) OrAcqRel(mask int64) int64
- func (a *Int64) OrAcquire(mask int64) int64
- func (a *Int64) OrRelaxed(mask int64) int64
- func (a *Int64) OrRelease(mask int64) int64
- func (a *Int64) Store(val int64)
- func (a *Int64) StoreRelaxed(val int64)
- func (a *Int64) StoreRelease(val int64)
- func (a *Int64) Sub(delta int64) int64
- func (a *Int64) SubAcqRel(delta int64) int64
- func (a *Int64) SubAcquire(delta int64) int64
- func (a *Int64) SubRelaxed(delta int64) int64
- func (a *Int64) SubRelease(delta int64) int64
- func (a *Int64) Swap(new int64) int64
- func (a *Int64) SwapAcqRel(new int64) int64
- func (a *Int64) SwapAcquire(new int64) int64
- func (a *Int64) SwapRelaxed(new int64) int64
- func (a *Int64) SwapRelease(new int64) int64
- func (a *Int64) Xor(mask int64) int64
- func (a *Int64) XorAcqRel(mask int64) int64
- func (a *Int64) XorAcquire(mask int64) int64
- func (a *Int64) XorRelaxed(mask int64) int64
- func (a *Int64) XorRelease(mask int64) int64
- type Int64Padded
- type MemoryOrder
- func (o MemoryOrder) AddInt128(addr *Int128, deltaLo, deltaHi int64) (oldLo, oldHi int64)
- func (o MemoryOrder) AddInt32(addr *int32, delta int32) (new int32)
- func (o MemoryOrder) AddInt64(addr *int64, delta int64) (new int64)
- func (o MemoryOrder) AddUint128(addr *Uint128, deltaLo, deltaHi uint64) (oldLo, oldHi uint64)
- func (o MemoryOrder) AddUint32(addr *uint32, delta uint32) (new uint32)
- func (o MemoryOrder) AddUint64(addr *uint64, delta uint64) (new uint64)
- func (o MemoryOrder) AddUintptr(addr *uintptr, delta uintptr) (new uintptr)
- func (o MemoryOrder) AndInt32(addr *int32, mask int32) (old int32)
- func (o MemoryOrder) AndInt64(addr *int64, mask int64) (old int64)
- func (o MemoryOrder) AndUint32(addr *uint32, mask uint32) (old uint32)
- func (o MemoryOrder) AndUint64(addr *uint64, mask uint64) (old uint64)
- func (o MemoryOrder) AndUintptr(addr *uintptr, mask uintptr) (old uintptr)
- func (o MemoryOrder) CompareAndSwapBool(addr *uint32, old, new bool) (swapped bool)
- func (o MemoryOrder) CompareAndSwapInt128(addr *Int128, oldLo, oldHi, newLo, newHi int64) (swapped bool)
- func (o MemoryOrder) CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool)
- func (o MemoryOrder) CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool)
- func (o MemoryOrder) CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)
- func (o MemoryOrder) CompareAndSwapUint128(addr *Uint128, oldLo, oldHi, newLo, newHi uint64) (swapped bool)
- func (o MemoryOrder) CompareAndSwapUint32(addr *uint32, old, new uint32) (swapped bool)
- func (o MemoryOrder) CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool)
- func (o MemoryOrder) CompareAndSwapUintptr(addr *uintptr, old, new uintptr) (swapped bool)
- func (o MemoryOrder) CompareExchangeInt128(addr *Int128, oldLo, oldHi, newLo, newHi int64) (prevLo, prevHi int64)
- func (o MemoryOrder) CompareExchangeInt32(addr *int32, old, new int32) (prev int32)
- func (o MemoryOrder) CompareExchangeInt64(addr *int64, old, new int64) (prev int64)
- func (o MemoryOrder) CompareExchangePointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (prev unsafe.Pointer)
- func (o MemoryOrder) CompareExchangeUint128(addr *Uint128, oldLo, oldHi, newLo, newHi uint64) (prevLo, prevHi uint64)
- func (o MemoryOrder) CompareExchangeUint32(addr *uint32, old, new uint32) (prev uint32)
- func (o MemoryOrder) CompareExchangeUint64(addr *uint64, old, new uint64) (prev uint64)
- func (o MemoryOrder) CompareExchangeUintptr(addr *uintptr, old, new uintptr) (prev uintptr)
- func (o MemoryOrder) LoadBool(addr *uint32) bool
- func (o MemoryOrder) LoadInt128(addr *Int128) (lo, hi int64)
- func (o MemoryOrder) LoadInt32(addr *int32) int32
- func (o MemoryOrder) LoadInt64(addr *int64) int64
- func (o MemoryOrder) LoadPointer(addr *unsafe.Pointer) unsafe.Pointer
- func (o MemoryOrder) LoadUint128(addr *Uint128) (lo, hi uint64)
- func (o MemoryOrder) LoadUint32(addr *uint32) uint32
- func (o MemoryOrder) LoadUint64(addr *uint64) uint64
- func (o MemoryOrder) LoadUintptr(addr *uintptr) uintptr
- func (o MemoryOrder) MaxInt32(addr *int32, val int32) (old int32)
- func (o MemoryOrder) MaxInt64(addr *int64, val int64) (old int64)
- func (o MemoryOrder) MaxUint32(addr *uint32, val uint32) (old uint32)
- func (o MemoryOrder) MaxUint64(addr *uint64, val uint64) (old uint64)
- func (o MemoryOrder) MaxUintptr(addr *uintptr, val uintptr) (old uintptr)
- func (o MemoryOrder) MinInt32(addr *int32, val int32) (old int32)
- func (o MemoryOrder) MinInt64(addr *int64, val int64) (old int64)
- func (o MemoryOrder) MinUint32(addr *uint32, val uint32) (old uint32)
- func (o MemoryOrder) MinUint64(addr *uint64, val uint64) (old uint64)
- func (o MemoryOrder) MinUintptr(addr *uintptr, val uintptr) (old uintptr)
- func (o MemoryOrder) OrInt32(addr *int32, mask int32) (old int32)
- func (o MemoryOrder) OrInt64(addr *int64, mask int64) (old int64)
- func (o MemoryOrder) OrUint32(addr *uint32, mask uint32) (old uint32)
- func (o MemoryOrder) OrUint64(addr *uint64, mask uint64) (old uint64)
- func (o MemoryOrder) OrUintptr(addr *uintptr, mask uintptr) (old uintptr)
- func (o MemoryOrder) StoreBool(addr *uint32, val bool)
- func (o MemoryOrder) StoreInt128(addr *Int128, lo, hi int64)
- func (o MemoryOrder) StoreInt32(addr *int32, val int32)
- func (o MemoryOrder) StoreInt64(addr *int64, val int64)
- func (o MemoryOrder) StorePointer(addr *unsafe.Pointer, val unsafe.Pointer)
- func (o MemoryOrder) StoreUint128(addr *Uint128, lo, hi uint64)
- func (o MemoryOrder) StoreUint32(addr *uint32, val uint32)
- func (o MemoryOrder) StoreUint64(addr *uint64, val uint64)
- func (o MemoryOrder) StoreUintptr(addr *uintptr, val uintptr)
- func (o MemoryOrder) SwapBool(addr *uint32, new bool) (old bool)
- func (o MemoryOrder) SwapInt128(addr *Int128, newLo, newHi int64) (oldLo, oldHi int64)
- func (o MemoryOrder) SwapInt32(addr *int32, new int32) (old int32)
- func (o MemoryOrder) SwapInt64(addr *int64, new int64) (old int64)
- func (o MemoryOrder) SwapPointer(addr *unsafe.Pointer, new unsafe.Pointer) (old unsafe.Pointer)
- func (o MemoryOrder) SwapUint128(addr *Uint128, newLo, newHi uint64) (oldLo, oldHi uint64)
- func (o MemoryOrder) SwapUint32(addr *uint32, new uint32) (old uint32)
- func (o MemoryOrder) SwapUint64(addr *uint64, new uint64) (old uint64)
- func (o MemoryOrder) SwapUintptr(addr *uintptr, new uintptr) (old uintptr)
- func (o MemoryOrder) XorInt32(addr *int32, mask int32) (old int32)
- func (o MemoryOrder) XorInt64(addr *int64, mask int64) (old int64)
- func (o MemoryOrder) XorUint32(addr *uint32, mask uint32) (old uint32)
- func (o MemoryOrder) XorUint64(addr *uint64, mask uint64) (old uint64)
- func (o MemoryOrder) XorUintptr(addr *uintptr, mask uintptr) (old uintptr)
- type Pointer
- func (a *Pointer[T]) CompareAndSwap(old, new *T) bool
- func (a *Pointer[T]) CompareAndSwapAcqRel(old, new *T) bool
- func (a *Pointer[T]) CompareAndSwapAcquire(old, new *T) bool
- func (a *Pointer[T]) CompareAndSwapRelaxed(old, new *T) bool
- func (a *Pointer[T]) CompareAndSwapRelease(old, new *T) bool
- func (a *Pointer[T]) CompareExchange(old, new *T) *T
- func (a *Pointer[T]) CompareExchangeAcqRel(old, new *T) *T
- func (a *Pointer[T]) CompareExchangeAcquire(old, new *T) *T
- func (a *Pointer[T]) CompareExchangeRelaxed(old, new *T) *T
- func (a *Pointer[T]) CompareExchangeRelease(old, new *T) *T
- func (a *Pointer[T]) Load() *T
- func (a *Pointer[T]) LoadAcquire() *T
- func (a *Pointer[T]) LoadRelaxed() *T
- func (a *Pointer[T]) Store(val *T)
- func (a *Pointer[T]) StoreRelaxed(val *T)
- func (a *Pointer[T]) StoreRelease(val *T)
- func (a *Pointer[T]) Swap(new *T) *T
- func (a *Pointer[T]) SwapAcqRel(new *T) *T
- func (a *Pointer[T]) SwapAcquire(new *T) *T
- func (a *Pointer[T]) SwapRelaxed(new *T) *T
- func (a *Pointer[T]) SwapRelease(new *T) *T
- type Uint128
- func (a *Uint128) Add(deltaLo, deltaHi uint64) (newLo, newHi uint64)
- func (a *Uint128) AddRelaxed(deltaLo, deltaHi uint64) (newLo, newHi uint64)
- func (a *Uint128) CompareAndSwap(oldLo, oldHi, newLo, newHi uint64) bool
- func (a *Uint128) CompareAndSwapAcqRel(oldLo, oldHi, newLo, newHi uint64) bool
- func (a *Uint128) CompareAndSwapAcquire(oldLo, oldHi, newLo, newHi uint64) bool
- func (a *Uint128) CompareAndSwapRelaxed(oldLo, oldHi, newLo, newHi uint64) bool
- func (a *Uint128) CompareAndSwapRelease(oldLo, oldHi, newLo, newHi uint64) bool
- func (a *Uint128) CompareExchange(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)
- func (a *Uint128) CompareExchangeAcqRel(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)
- func (a *Uint128) CompareExchangeAcquire(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)
- func (a *Uint128) CompareExchangeRelaxed(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)
- func (a *Uint128) CompareExchangeRelease(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)
- func (a *Uint128) Dec() (newLo, newHi uint64)
- func (a *Uint128) DecRelaxed() (newLo, newHi uint64)
- func (a *Uint128) Equal(lo, hi uint64) bool
- func (a *Uint128) EqualRelaxed(lo, hi uint64) bool
- func (a *Uint128) Greater(lo, hi uint64) bool
- func (a *Uint128) GreaterOrEqual(lo, hi uint64) bool
- func (a *Uint128) GreaterOrEqualRelaxed(lo, hi uint64) bool
- func (a *Uint128) GreaterRelaxed(lo, hi uint64) bool
- func (a *Uint128) Inc() (newLo, newHi uint64)
- func (a *Uint128) IncRelaxed() (newLo, newHi uint64)
- func (a *Uint128) Less(lo, hi uint64) bool
- func (a *Uint128) LessOrEqual(lo, hi uint64) bool
- func (a *Uint128) LessOrEqualRelaxed(lo, hi uint64) bool
- func (a *Uint128) LessRelaxed(lo, hi uint64) bool
- func (a *Uint128) Load() (lo, hi uint64)
- func (a *Uint128) LoadAcquire() (lo, hi uint64)
- func (a *Uint128) LoadRelaxed() (lo, hi uint64)
- func (a *Uint128) Store(lo, hi uint64)
- func (a *Uint128) StoreRelaxed(lo, hi uint64)
- func (a *Uint128) StoreRelease(lo, hi uint64)
- func (a *Uint128) Sub(deltaLo, deltaHi uint64) (newLo, newHi uint64)
- func (a *Uint128) SubRelaxed(deltaLo, deltaHi uint64) (newLo, newHi uint64)
- func (a *Uint128) Swap(newLo, newHi uint64) (oldLo, oldHi uint64)
- func (a *Uint128) SwapAcqRel(newLo, newHi uint64) (oldLo, oldHi uint64)
- func (a *Uint128) SwapAcquire(newLo, newHi uint64) (oldLo, oldHi uint64)
- func (a *Uint128) SwapRelaxed(newLo, newHi uint64) (oldLo, oldHi uint64)
- func (a *Uint128) SwapRelease(newLo, newHi uint64) (oldLo, oldHi uint64)
- type Uint128Padded
- type Uint32
- func (a *Uint32) Add(delta uint32) uint32
- func (a *Uint32) AddAcqRel(delta uint32) uint32
- func (a *Uint32) AddAcquire(delta uint32) uint32
- func (a *Uint32) AddRelaxed(delta uint32) uint32
- func (a *Uint32) AddRelease(delta uint32) uint32
- func (a *Uint32) And(mask uint32) uint32
- func (a *Uint32) AndAcqRel(mask uint32) uint32
- func (a *Uint32) AndAcquire(mask uint32) uint32
- func (a *Uint32) AndRelaxed(mask uint32) uint32
- func (a *Uint32) AndRelease(mask uint32) uint32
- func (a *Uint32) CompareAndSwap(old, new uint32) bool
- func (a *Uint32) CompareAndSwapAcqRel(old, new uint32) bool
- func (a *Uint32) CompareAndSwapAcquire(old, new uint32) bool
- func (a *Uint32) CompareAndSwapRelaxed(old, new uint32) bool
- func (a *Uint32) CompareAndSwapRelease(old, new uint32) bool
- func (a *Uint32) CompareExchange(old, new uint32) uint32
- func (a *Uint32) CompareExchangeAcqRel(old, new uint32) uint32
- func (a *Uint32) CompareExchangeAcquire(old, new uint32) uint32
- func (a *Uint32) CompareExchangeRelaxed(old, new uint32) uint32
- func (a *Uint32) CompareExchangeRelease(old, new uint32) uint32
- func (a *Uint32) Load() uint32
- func (a *Uint32) LoadAcquire() uint32
- func (a *Uint32) LoadRelaxed() uint32
- func (a *Uint32) Max(val uint32) uint32
- func (a *Uint32) MaxRelaxed(val uint32) uint32
- func (a *Uint32) Min(val uint32) uint32
- func (a *Uint32) MinRelaxed(val uint32) uint32
- func (a *Uint32) Or(mask uint32) uint32
- func (a *Uint32) OrAcqRel(mask uint32) uint32
- func (a *Uint32) OrAcquire(mask uint32) uint32
- func (a *Uint32) OrRelaxed(mask uint32) uint32
- func (a *Uint32) OrRelease(mask uint32) uint32
- func (a *Uint32) Store(val uint32)
- func (a *Uint32) StoreRelaxed(val uint32)
- func (a *Uint32) StoreRelease(val uint32)
- func (a *Uint32) Sub(delta uint32) uint32
- func (a *Uint32) SubAcqRel(delta uint32) uint32
- func (a *Uint32) SubAcquire(delta uint32) uint32
- func (a *Uint32) SubRelaxed(delta uint32) uint32
- func (a *Uint32) SubRelease(delta uint32) uint32
- func (a *Uint32) Swap(new uint32) uint32
- func (a *Uint32) SwapAcqRel(new uint32) uint32
- func (a *Uint32) SwapAcquire(new uint32) uint32
- func (a *Uint32) SwapRelaxed(new uint32) uint32
- func (a *Uint32) SwapRelease(new uint32) uint32
- func (a *Uint32) Xor(mask uint32) uint32
- func (a *Uint32) XorAcqRel(mask uint32) uint32
- func (a *Uint32) XorAcquire(mask uint32) uint32
- func (a *Uint32) XorRelaxed(mask uint32) uint32
- func (a *Uint32) XorRelease(mask uint32) uint32
- type Uint32Padded
- type Uint64
- func (a *Uint64) Add(delta uint64) uint64
- func (a *Uint64) AddAcqRel(delta uint64) uint64
- func (a *Uint64) AddAcquire(delta uint64) uint64
- func (a *Uint64) AddRelaxed(delta uint64) uint64
- func (a *Uint64) AddRelease(delta uint64) uint64
- func (a *Uint64) And(mask uint64) uint64
- func (a *Uint64) AndAcqRel(mask uint64) uint64
- func (a *Uint64) AndAcquire(mask uint64) uint64
- func (a *Uint64) AndRelaxed(mask uint64) uint64
- func (a *Uint64) AndRelease(mask uint64) uint64
- func (a *Uint64) CompareAndSwap(old, new uint64) bool
- func (a *Uint64) CompareAndSwapAcqRel(old, new uint64) bool
- func (a *Uint64) CompareAndSwapAcquire(old, new uint64) bool
- func (a *Uint64) CompareAndSwapRelaxed(old, new uint64) bool
- func (a *Uint64) CompareAndSwapRelease(old, new uint64) bool
- func (a *Uint64) CompareExchange(old, new uint64) uint64
- func (a *Uint64) CompareExchangeAcqRel(old, new uint64) uint64
- func (a *Uint64) CompareExchangeAcquire(old, new uint64) uint64
- func (a *Uint64) CompareExchangeRelaxed(old, new uint64) uint64
- func (a *Uint64) CompareExchangeRelease(old, new uint64) uint64
- func (a *Uint64) Load() uint64
- func (a *Uint64) LoadAcquire() uint64
- func (a *Uint64) LoadRelaxed() uint64
- func (a *Uint64) Max(val uint64) uint64
- func (a *Uint64) MaxRelaxed(val uint64) uint64
- func (a *Uint64) Min(val uint64) uint64
- func (a *Uint64) MinRelaxed(val uint64) uint64
- func (a *Uint64) Or(mask uint64) uint64
- func (a *Uint64) OrAcqRel(mask uint64) uint64
- func (a *Uint64) OrAcquire(mask uint64) uint64
- func (a *Uint64) OrRelaxed(mask uint64) uint64
- func (a *Uint64) OrRelease(mask uint64) uint64
- func (a *Uint64) Store(val uint64)
- func (a *Uint64) StoreRelaxed(val uint64)
- func (a *Uint64) StoreRelease(val uint64)
- func (a *Uint64) Sub(delta uint64) uint64
- func (a *Uint64) SubAcqRel(delta uint64) uint64
- func (a *Uint64) SubAcquire(delta uint64) uint64
- func (a *Uint64) SubRelaxed(delta uint64) uint64
- func (a *Uint64) SubRelease(delta uint64) uint64
- func (a *Uint64) Swap(new uint64) uint64
- func (a *Uint64) SwapAcqRel(new uint64) uint64
- func (a *Uint64) SwapAcquire(new uint64) uint64
- func (a *Uint64) SwapRelaxed(new uint64) uint64
- func (a *Uint64) SwapRelease(new uint64) uint64
- func (a *Uint64) Xor(mask uint64) uint64
- func (a *Uint64) XorAcqRel(mask uint64) uint64
- func (a *Uint64) XorAcquire(mask uint64) uint64
- func (a *Uint64) XorRelaxed(mask uint64) uint64
- func (a *Uint64) XorRelease(mask uint64) uint64
- type Uint64Padded
- type Uintptr
- func (a *Uintptr) Add(delta uintptr) uintptr
- func (a *Uintptr) AddAcqRel(delta uintptr) uintptr
- func (a *Uintptr) AddAcquire(delta uintptr) uintptr
- func (a *Uintptr) AddRelaxed(delta uintptr) uintptr
- func (a *Uintptr) AddRelease(delta uintptr) uintptr
- func (a *Uintptr) And(mask uintptr) uintptr
- func (a *Uintptr) AndAcqRel(mask uintptr) uintptr
- func (a *Uintptr) AndAcquire(mask uintptr) uintptr
- func (a *Uintptr) AndRelaxed(mask uintptr) uintptr
- func (a *Uintptr) AndRelease(mask uintptr) uintptr
- func (a *Uintptr) CompareAndSwap(old, new uintptr) bool
- func (a *Uintptr) CompareAndSwapAcqRel(old, new uintptr) bool
- func (a *Uintptr) CompareAndSwapAcquire(old, new uintptr) bool
- func (a *Uintptr) CompareAndSwapRelaxed(old, new uintptr) bool
- func (a *Uintptr) CompareAndSwapRelease(old, new uintptr) bool
- func (a *Uintptr) CompareExchange(old, new uintptr) uintptr
- func (a *Uintptr) CompareExchangeAcqRel(old, new uintptr) uintptr
- func (a *Uintptr) CompareExchangeAcquire(old, new uintptr) uintptr
- func (a *Uintptr) CompareExchangeRelaxed(old, new uintptr) uintptr
- func (a *Uintptr) CompareExchangeRelease(old, new uintptr) uintptr
- func (a *Uintptr) Load() uintptr
- func (a *Uintptr) LoadAcquire() uintptr
- func (a *Uintptr) LoadRelaxed() uintptr
- func (a *Uintptr) Max(val uintptr) uintptr
- func (a *Uintptr) MaxRelaxed(val uintptr) uintptr
- func (a *Uintptr) Min(val uintptr) uintptr
- func (a *Uintptr) MinRelaxed(val uintptr) uintptr
- func (a *Uintptr) Or(mask uintptr) uintptr
- func (a *Uintptr) OrAcqRel(mask uintptr) uintptr
- func (a *Uintptr) OrAcquire(mask uintptr) uintptr
- func (a *Uintptr) OrRelaxed(mask uintptr) uintptr
- func (a *Uintptr) OrRelease(mask uintptr) uintptr
- func (a *Uintptr) Store(val uintptr)
- func (a *Uintptr) StoreRelaxed(val uintptr)
- func (a *Uintptr) StoreRelease(val uintptr)
- func (a *Uintptr) Sub(delta uintptr) uintptr
- func (a *Uintptr) SubAcqRel(delta uintptr) uintptr
- func (a *Uintptr) SubAcquire(delta uintptr) uintptr
- func (a *Uintptr) SubRelaxed(delta uintptr) uintptr
- func (a *Uintptr) SubRelease(delta uintptr) uintptr
- func (a *Uintptr) Swap(new uintptr) uintptr
- func (a *Uintptr) SwapAcqRel(new uintptr) uintptr
- func (a *Uintptr) SwapAcquire(new uintptr) uintptr
- func (a *Uintptr) SwapRelaxed(new uintptr) uintptr
- func (a *Uintptr) SwapRelease(new uintptr) uintptr
- func (a *Uintptr) Xor(mask uintptr) uintptr
- func (a *Uintptr) XorAcqRel(mask uintptr) uintptr
- func (a *Uintptr) XorAcquire(mask uintptr) uintptr
- func (a *Uintptr) XorRelaxed(mask uintptr) uintptr
- func (a *Uintptr) XorRelease(mask uintptr) uintptr
- type UintptrPadded
Constants ¶
const CacheLineSize = 64
CacheLineSize is the cache line size on x86-64 processors. Intel and AMD processors use 64-byte cache lines.
Variables ¶
This section is empty.
Functions ¶
func BarrierAcqRel ¶
func BarrierAcqRel()
BarrierAcqRel issues a full memory barrier (acquire + release). Provides both acquire and release semantics.
func BarrierAcquire ¶
func BarrierAcquire()
BarrierAcquire issues an acquire memory barrier. Subsequent memory operations cannot be reordered before this barrier.
func BarrierRelease ¶
func BarrierRelease()
BarrierRelease issues a release memory barrier. Prior memory operations cannot be reordered after this barrier.
func CanPlaceAligned16 ¶
CanPlaceAligned16 reports whether a 16-byte aligned value can be placed in p starting at offset off. Returns true if there is sufficient space for alignment padding plus 16 bytes.
func CanPlaceAligned4 ¶
CanPlaceAligned4 reports whether a 4-byte aligned value can be placed in p starting at offset off. Returns true if there is sufficient space for alignment padding plus 4 bytes.
func CanPlaceAligned8 ¶
CanPlaceAligned8 reports whether an 8-byte aligned value can be placed in p starting at offset off. Returns true if there is sufficient space for alignment padding plus 8 bytes.
func CanPlaceCacheAligned ¶
CanPlaceCacheAligned reports whether a cache-line aligned value of the given size can be placed in p starting at offset off.
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
Allocator is a sequential allocator for placing atomic values in a buffer. It provides methods to allocate properly aligned atomic types.
func NewAllocator ¶
NewAllocator creates a new Allocator backed by the given buffer. The caller must keep buf reachable for the lifetime of all allocated values.
func (*Allocator) CacheAlignedBool ¶
func (a *Allocator) CacheAlignedBool() *BoolPadded
CacheAlignedBool allocates and returns a BoolPadded at a cache-line aligned address.
func (*Allocator) CacheAlignedInt128 ¶
func (a *Allocator) CacheAlignedInt128() *Int128Padded
CacheAlignedInt128 allocates and returns an Int128Padded at a cache-line aligned address.
func (*Allocator) CacheAlignedInt32 ¶
func (a *Allocator) CacheAlignedInt32() *Int32Padded
CacheAlignedInt32 allocates and returns an Int32Padded at a cache-line aligned address.
func (*Allocator) CacheAlignedInt64 ¶
func (a *Allocator) CacheAlignedInt64() *Int64Padded
CacheAlignedInt64 allocates and returns an Int64Padded at a cache-line aligned address.
func (*Allocator) CacheAlignedUint128 ¶
func (a *Allocator) CacheAlignedUint128() *Uint128Padded
CacheAlignedUint128 allocates and returns a Uint128Padded at a cache-line aligned address.
func (*Allocator) CacheAlignedUint32 ¶
func (a *Allocator) CacheAlignedUint32() *Uint32Padded
CacheAlignedUint32 allocates and returns a Uint32Padded at a cache-line aligned address.
func (*Allocator) CacheAlignedUint64 ¶
func (a *Allocator) CacheAlignedUint64() *Uint64Padded
CacheAlignedUint64 allocates and returns a Uint64Padded at a cache-line aligned address.
func (*Allocator) CacheAlignedUintptr ¶
func (a *Allocator) CacheAlignedUintptr() *UintptrPadded
CacheAlignedUintptr allocates and returns a UintptrPadded at a cache-line aligned address.
func (*Allocator) Reset ¶
func (a *Allocator) Reset()
Reset resets the allocator to the beginning of the buffer. Previously allocated values remain valid but may be overwritten.
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool represents an atomic boolean.
The zero value is false. Bool is safe for concurrent use. Must not be copied after first use.
func PlaceAlignedBool ¶
PlaceAlignedBool places a Bool at a 4-byte aligned address in p.
func (*Bool) CompareAndSwap ¶
CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.
func (*Bool) CompareAndSwapAcqRel ¶
CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.
func (*Bool) CompareAndSwapAcquire ¶
CompareAndSwapAcquire atomically compares and swaps with acquire ordering.
func (*Bool) CompareAndSwapRelaxed ¶
CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.
func (*Bool) CompareAndSwapRelease ¶
CompareAndSwapRelease atomically compares and swaps with release ordering.
func (*Bool) LoadAcquire ¶
LoadAcquire atomically loads and returns the value with acquire ordering.
func (*Bool) LoadRelaxed ¶
LoadRelaxed atomically loads and returns the value with relaxed ordering.
func (*Bool) StoreRelaxed ¶
StoreRelaxed atomically stores val with relaxed ordering.
func (*Bool) StoreRelease ¶
StoreRelease atomically stores val with release ordering.
func (*Bool) Swap ¶
Swap atomically swaps the value and returns the old value with acquire-release ordering.
func (*Bool) SwapAcqRel ¶
SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.
func (*Bool) SwapAcquire ¶
SwapAcquire atomically swaps the value and returns the old value with acquire ordering.
func (*Bool) SwapRelaxed ¶
SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.
func (*Bool) SwapRelease ¶
SwapRelease atomically swaps the value and returns the old value with release ordering.
type BoolPadded ¶
type BoolPadded struct {
Bool
// contains filtered or unexported fields
}
BoolPadded is a Bool padded to cache line size.
func PlaceCacheAlignedBool ¶
func PlaceCacheAlignedBool(p []byte, off int) (n int, a *BoolPadded)
PlaceCacheAlignedBool places a BoolPadded at a cache-line aligned address.
type Int128 ¶
type Int128 struct {
// contains filtered or unexported fields
}
Int128 represents an atomic 128-bit signed integer.
The zero value is 0. Int128 is safe for concurrent use. Must not be copied after first use.
Int128 requires 16-byte alignment. Use PlaceAlignedInt128 to ensure proper alignment when embedding in byte slices or shared memory.
func PlaceAlignedInt128 ¶
PlaceAlignedInt128 places an Int128 at a 16-byte aligned address in p.
func (*Int128) Add ¶
Add atomically adds (deltaLo, deltaHi) and returns the new value. Uses acquire-release ordering.
func (*Int128) AddRelaxed ¶
AddRelaxed atomically adds (deltaLo, deltaHi) and returns the new value.
func (*Int128) CompareAndSwap ¶
CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.
func (*Int128) CompareAndSwapAcqRel ¶
CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.
func (*Int128) CompareAndSwapAcquire ¶
CompareAndSwapAcquire atomically compares and swaps with acquire ordering.
func (*Int128) CompareAndSwapRelaxed ¶
CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.
func (*Int128) CompareAndSwapRelease ¶
CompareAndSwapRelease atomically compares and swaps with release ordering.
func (*Int128) CompareExchange ¶
CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.
func (*Int128) CompareExchangeAcqRel ¶
CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.
func (*Int128) CompareExchangeAcquire ¶
CompareExchangeAcquire atomically compares and swaps with acquire ordering.
func (*Int128) CompareExchangeRelaxed ¶
CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.
func (*Int128) CompareExchangeRelease ¶
CompareExchangeRelease atomically compares and swaps with release ordering.
func (*Int128) Dec ¶
Dec atomically decrements by 1 and returns the new value. Uses acquire-release ordering.
func (*Int128) DecRelaxed ¶
DecRelaxed atomically decrements by 1 and returns the new value.
func (*Int128) EqualRelaxed ¶
EqualRelaxed atomically loads and compares with relaxed ordering.
func (*Int128) Greater ¶
Greater atomically loads and returns true if value > (lo, hi). Uses acquire ordering. Comparison is signed.
func (*Int128) GreaterOrEqual ¶
GreaterOrEqual atomically loads and returns true if value >= (lo, hi). Uses acquire ordering. Comparison is signed.
func (*Int128) GreaterOrEqualRelaxed ¶
GreaterOrEqualRelaxed atomically loads and compares with relaxed ordering.
func (*Int128) GreaterRelaxed ¶
GreaterRelaxed atomically loads and compares with relaxed ordering.
func (*Int128) Inc ¶
Inc atomically increments by 1 and returns the new value. Uses acquire-release ordering.
func (*Int128) IncRelaxed ¶
IncRelaxed atomically increments by 1 and returns the new value.
func (*Int128) Less ¶
Less atomically loads and returns true if value < (lo, hi). Uses acquire ordering. Comparison is signed.
func (*Int128) LessOrEqual ¶
LessOrEqual atomically loads and returns true if value <= (lo, hi). Uses acquire ordering. Comparison is signed.
func (*Int128) LessOrEqualRelaxed ¶
LessOrEqualRelaxed atomically loads and compares with relaxed ordering.
func (*Int128) LessRelaxed ¶
LessRelaxed atomically loads and compares with relaxed ordering.
func (*Int128) Load ¶
Load atomically loads and returns the value with relaxed ordering. Returns (lo, hi) where the full value is (hi << 64) | lo.
func (*Int128) LoadAcquire ¶
LoadAcquire atomically loads and returns the value with acquire ordering.
func (*Int128) LoadRelaxed ¶
LoadRelaxed atomically loads and returns the value with relaxed ordering.
func (*Int128) StoreRelaxed ¶
StoreRelaxed atomically stores val with relaxed ordering.
func (*Int128) StoreRelease ¶
StoreRelease atomically stores val with release ordering.
func (*Int128) Sub ¶
Sub atomically subtracts (deltaLo, deltaHi) and returns the new value. Uses acquire-release ordering.
func (*Int128) SubRelaxed ¶
SubRelaxed atomically subtracts (deltaLo, deltaHi) and returns the new value.
func (*Int128) Swap ¶
Swap atomically stores new value and returns the old value. Uses acquire-release ordering.
func (*Int128) SwapAcqRel ¶
SwapAcqRel atomically stores new value and returns the old value with acquire-release ordering.
func (*Int128) SwapAcquire ¶
SwapAcquire atomically stores new value and returns the old value with acquire ordering.
func (*Int128) SwapRelaxed ¶
SwapRelaxed atomically stores new value and returns the old value with relaxed ordering.
func (*Int128) SwapRelease ¶
SwapRelease atomically stores new value and returns the old value with release ordering.
type Int128Padded ¶
type Int128Padded struct {
Int128
// contains filtered or unexported fields
}
Int128Padded is an Int128 padded to cache line size.
func PlaceCacheAlignedInt128 ¶
func PlaceCacheAlignedInt128(p []byte, off int) (n int, a *Int128Padded)
PlaceCacheAlignedInt128 places an Int128Padded at a cache-line aligned address.
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 represents an atomic 32-bit signed integer.
The zero value is 0. Int32 is safe for concurrent use. Must not be copied after first use.
func PlaceAlignedInt32 ¶
PlaceAlignedInt32 places an Int32 at a 4-byte aligned address in p. Returns the number of bytes consumed (padding + 4) and a pointer to the Int32. Panics if there is insufficient space.
func (*Int32) Add ¶
Add atomically adds delta and returns the new value with acquire-release ordering.
func (*Int32) AddAcqRel ¶
AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.
func (*Int32) AddAcquire ¶
AddAcquire atomically adds delta and returns the new value with acquire ordering.
func (*Int32) AddRelaxed ¶
AddRelaxed atomically adds delta and returns the new value with relaxed ordering.
func (*Int32) AddRelease ¶
AddRelease atomically adds delta and returns the new value with release ordering.
func (*Int32) And ¶
And atomically performs bitwise AND and returns the old value with acquire-release ordering.
func (*Int32) AndAcquire ¶
AndAcquire atomically performs bitwise AND with acquire ordering.
func (*Int32) AndRelaxed ¶
AndRelaxed atomically performs bitwise AND with relaxed ordering.
func (*Int32) AndRelease ¶
AndRelease atomically performs bitwise AND with release ordering.
func (*Int32) CompareAndSwap ¶
CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.
func (*Int32) CompareAndSwapAcqRel ¶
CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.
func (*Int32) CompareAndSwapAcquire ¶
CompareAndSwapAcquire atomically compares and swaps with acquire ordering.
func (*Int32) CompareAndSwapRelaxed ¶
CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.
func (*Int32) CompareAndSwapRelease ¶
CompareAndSwapRelease atomically compares and swaps with release ordering.
func (*Int32) CompareExchange ¶
CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.
func (*Int32) CompareExchangeAcqRel ¶
CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.
func (*Int32) CompareExchangeAcquire ¶
CompareExchangeAcquire atomically compares and swaps with acquire ordering.
func (*Int32) CompareExchangeRelaxed ¶
CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.
func (*Int32) CompareExchangeRelease ¶
CompareExchangeRelease atomically compares and swaps with release ordering.
func (*Int32) LoadAcquire ¶
LoadAcquire atomically loads and returns the value with acquire ordering.
func (*Int32) LoadRelaxed ¶
LoadRelaxed atomically loads and returns the value with relaxed ordering.
func (*Int32) Max ¶
Max atomically stores the maximum of current and val, returning the old value. Uses acquire-release ordering.
func (*Int32) MaxRelaxed ¶
MaxRelaxed atomically stores the maximum with relaxed ordering.
func (*Int32) Min ¶
Min atomically stores the minimum of current and val, returning the old value. Uses acquire-release ordering.
func (*Int32) MinRelaxed ¶
MinRelaxed atomically stores the minimum with relaxed ordering.
func (*Int32) Or ¶
Or atomically performs bitwise OR and returns the old value with acquire-release ordering.
func (*Int32) StoreRelaxed ¶
StoreRelaxed atomically stores val with relaxed ordering.
func (*Int32) StoreRelease ¶
StoreRelease atomically stores val with release ordering.
func (*Int32) Sub ¶
Sub atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Int32) SubAcqRel ¶
SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Int32) SubAcquire ¶
SubAcquire atomically subtracts delta and returns the new value with acquire ordering.
func (*Int32) SubRelaxed ¶
SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.
func (*Int32) SubRelease ¶
SubRelease atomically subtracts delta and returns the new value with release ordering.
func (*Int32) Swap ¶
Swap atomically swaps the value and returns the old value with acquire-release ordering.
func (*Int32) SwapAcqRel ¶
SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.
func (*Int32) SwapAcquire ¶
SwapAcquire atomically swaps the value and returns the old value with acquire ordering.
func (*Int32) SwapRelaxed ¶
SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.
func (*Int32) SwapRelease ¶
SwapRelease atomically swaps the value and returns the old value with release ordering.
func (*Int32) Xor ¶
Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.
func (*Int32) XorAcquire ¶
XorAcquire atomically performs bitwise XOR with acquire ordering.
func (*Int32) XorRelaxed ¶
XorRelaxed atomically performs bitwise XOR with relaxed ordering.
func (*Int32) XorRelease ¶
XorRelease atomically performs bitwise XOR with release ordering.
type Int32Padded ¶
type Int32Padded struct {
Int32
// contains filtered or unexported fields
}
Int32Padded is an Int32 padded to cache line size.
func PlaceCacheAlignedInt32 ¶
func PlaceCacheAlignedInt32(p []byte, off int) (n int, a *Int32Padded)
PlaceCacheAlignedInt32 places an Int32Padded at a cache-line aligned address.
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 represents an atomic 64-bit signed integer.
The zero value is 0. Int64 is safe for concurrent use. Must not be copied after first use.
func PlaceAlignedInt64 ¶
PlaceAlignedInt64 places an Int64 at an 8-byte aligned address in p.
func (*Int64) Add ¶
Add atomically adds delta and returns the new value with acquire-release ordering.
func (*Int64) AddAcqRel ¶
AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.
func (*Int64) AddAcquire ¶
AddAcquire atomically adds delta and returns the new value with acquire ordering.
func (*Int64) AddRelaxed ¶
AddRelaxed atomically adds delta and returns the new value with relaxed ordering.
func (*Int64) AddRelease ¶
AddRelease atomically adds delta and returns the new value with release ordering.
func (*Int64) And ¶
And atomically performs bitwise AND and returns the old value with acquire-release ordering.
func (*Int64) AndAcquire ¶
AndAcquire atomically performs bitwise AND with acquire ordering.
func (*Int64) AndRelaxed ¶
AndRelaxed atomically performs bitwise AND with relaxed ordering.
func (*Int64) AndRelease ¶
AndRelease atomically performs bitwise AND with release ordering.
func (*Int64) CompareAndSwap ¶
CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.
func (*Int64) CompareAndSwapAcqRel ¶
CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.
func (*Int64) CompareAndSwapAcquire ¶
CompareAndSwapAcquire atomically compares and swaps with acquire ordering.
func (*Int64) CompareAndSwapRelaxed ¶
CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.
func (*Int64) CompareAndSwapRelease ¶
CompareAndSwapRelease atomically compares and swaps with release ordering.
func (*Int64) CompareExchange ¶
CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.
func (*Int64) CompareExchangeAcqRel ¶
CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.
func (*Int64) CompareExchangeAcquire ¶
CompareExchangeAcquire atomically compares and swaps with acquire ordering.
func (*Int64) CompareExchangeRelaxed ¶
CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.
func (*Int64) CompareExchangeRelease ¶
CompareExchangeRelease atomically compares and swaps with release ordering.
func (*Int64) LoadAcquire ¶
LoadAcquire atomically loads and returns the value with acquire ordering.
func (*Int64) LoadRelaxed ¶
LoadRelaxed atomically loads and returns the value with relaxed ordering.
func (*Int64) Max ¶
Max atomically stores the maximum of current and val, returning the old value. Uses acquire-release ordering.
func (*Int64) MaxRelaxed ¶
MaxRelaxed atomically stores the maximum with relaxed ordering.
func (*Int64) Min ¶
Min atomically stores the minimum of current and val, returning the old value. Uses acquire-release ordering.
func (*Int64) MinRelaxed ¶
MinRelaxed atomically stores the minimum with relaxed ordering.
func (*Int64) Or ¶
Or atomically performs bitwise OR and returns the old value with acquire-release ordering.
func (*Int64) StoreRelaxed ¶
StoreRelaxed atomically stores val with relaxed ordering.
func (*Int64) StoreRelease ¶
StoreRelease atomically stores val with release ordering.
func (*Int64) Sub ¶
Sub atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Int64) SubAcqRel ¶
SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Int64) SubAcquire ¶
SubAcquire atomically subtracts delta and returns the new value with acquire ordering.
func (*Int64) SubRelaxed ¶
SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.
func (*Int64) SubRelease ¶
SubRelease atomically subtracts delta and returns the new value with release ordering.
func (*Int64) Swap ¶
Swap atomically swaps the value and returns the old value with acquire-release ordering.
func (*Int64) SwapAcqRel ¶
SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.
func (*Int64) SwapAcquire ¶
SwapAcquire atomically swaps the value and returns the old value with acquire ordering.
func (*Int64) SwapRelaxed ¶
SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.
func (*Int64) SwapRelease ¶
SwapRelease atomically swaps the value and returns the old value with release ordering.
func (*Int64) Xor ¶
Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.
func (*Int64) XorAcquire ¶
XorAcquire atomically performs bitwise XOR with acquire ordering.
func (*Int64) XorRelaxed ¶
XorRelaxed atomically performs bitwise XOR with relaxed ordering.
func (*Int64) XorRelease ¶
XorRelease atomically performs bitwise XOR with release ordering.
type Int64Padded ¶
type Int64Padded struct {
Int64
// contains filtered or unexported fields
}
Int64Padded is an Int64 padded to cache line size.
func PlaceCacheAlignedInt64 ¶
func PlaceCacheAlignedInt64(p []byte, off int) (n int, a *Int64Padded)
PlaceCacheAlignedInt64 places an Int64Padded at a cache-line aligned address.
type MemoryOrder ¶
type MemoryOrder uint8
MemoryOrder specifies the memory ordering constraint for atomic operations.
MemoryOrder constants can be used as method receivers to perform atomic operations on raw pointers:
var x int64 atomix.Relaxed.StoreInt64(&x, 42) val := atomix.Acquire.LoadInt64(&x)
This is useful for operating on shared memory (e.g., io_uring rings) where wrapper types cannot be used.
Alignment: Pointers must be naturally aligned (int32 → 4-byte, int64 → 8-byte). Go guarantees alignment for declared variables. Unaligned pointers from unsafe operations may cause undefined behavior on some architectures.
const ( // Relaxed provides no ordering constraints; only atomicity is guaranteed. // Use for statistics counters and metrics that don't synchronize with // other memory operations. Relaxed MemoryOrder = iota // Acquire ensures subsequent operations cannot be reordered before the // atomic operation. Use when loading a pointer before dereferencing it. Acquire // Release ensures prior operations cannot be reordered after the atomic // operation. Use when publishing data after initialization. Release // AcqRel combines Acquire and Release semantics. Use for read-modify-write // operations in lock-free data structures. AcqRel )
func (MemoryOrder) AddInt128 ¶
func (o MemoryOrder) AddInt128(addr *Int128, deltaLo, deltaHi int64) (oldLo, oldHi int64)
AddInt128 atomically adds (deltaLo, deltaHi) to *addr and returns the old value. addr MUST be 16-byte aligned; use PlaceAlignedInt128 to ensure alignment. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AddInt32 ¶
func (o MemoryOrder) AddInt32(addr *int32, delta int32) (new int32)
AddInt32 atomically adds delta to *addr and returns the new value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AddInt64 ¶
func (o MemoryOrder) AddInt64(addr *int64, delta int64) (new int64)
AddInt64 atomically adds delta to *addr and returns the new value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AddUint128 ¶
func (o MemoryOrder) AddUint128(addr *Uint128, deltaLo, deltaHi uint64) (oldLo, oldHi uint64)
AddUint128 atomically adds (deltaLo, deltaHi) to *addr and returns the old value. addr MUST be 16-byte aligned; use PlaceAlignedUint128 to ensure alignment. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AddUint32 ¶
func (o MemoryOrder) AddUint32(addr *uint32, delta uint32) (new uint32)
AddUint32 atomically adds delta to *addr and returns the new value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AddUint64 ¶
func (o MemoryOrder) AddUint64(addr *uint64, delta uint64) (new uint64)
AddUint64 atomically adds delta to *addr and returns the new value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AddUintptr ¶
func (o MemoryOrder) AddUintptr(addr *uintptr, delta uintptr) (new uintptr)
AddUintptr atomically adds delta to *addr and returns the new value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AndInt32 ¶
func (o MemoryOrder) AndInt32(addr *int32, mask int32) (old int32)
AndInt32 atomically performs *addr &= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AndInt64 ¶
func (o MemoryOrder) AndInt64(addr *int64, mask int64) (old int64)
AndInt64 atomically performs *addr &= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AndUint32 ¶
func (o MemoryOrder) AndUint32(addr *uint32, mask uint32) (old uint32)
AndUint32 atomically performs *addr &= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AndUint64 ¶
func (o MemoryOrder) AndUint64(addr *uint64, mask uint64) (old uint64)
AndUint64 atomically performs *addr &= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) AndUintptr ¶
func (o MemoryOrder) AndUintptr(addr *uintptr, mask uintptr) (old uintptr)
AndUintptr atomically performs *addr &= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareAndSwapBool ¶
func (o MemoryOrder) CompareAndSwapBool(addr *uint32, old, new bool) (swapped bool)
CompareAndSwapBool atomically compares *addr with old and swaps if equal. Returns true if the swap was performed. addr points to a uint32 where 0 is false and 1 is true. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareAndSwapInt128 ¶
func (o MemoryOrder) CompareAndSwapInt128(addr *Int128, oldLo, oldHi, newLo, newHi int64) (swapped bool)
CompareAndSwapInt128 atomically compares *addr with (oldLo, oldHi) and swaps if equal. Returns true if the swap was performed. addr MUST be 16-byte aligned; use PlaceAlignedInt128 to ensure alignment. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareAndSwapInt32 ¶
func (o MemoryOrder) CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool)
CompareAndSwapInt32 atomically compares *addr with old and swaps if equal. Returns true if the swap was performed. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareAndSwapInt64 ¶
func (o MemoryOrder) CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool)
CompareAndSwapInt64 atomically compares *addr with old and swaps if equal. Returns true if the swap was performed. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareAndSwapPointer ¶
func (o MemoryOrder) CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)
CompareAndSwapPointer atomically compares *addr with old and swaps if equal. Returns true if the swap was performed. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareAndSwapUint128 ¶
func (o MemoryOrder) CompareAndSwapUint128(addr *Uint128, oldLo, oldHi, newLo, newHi uint64) (swapped bool)
CompareAndSwapUint128 atomically compares *addr with (oldLo, oldHi) and swaps if equal. Returns true if the swap was performed. addr MUST be 16-byte aligned; use PlaceAlignedUint128 to ensure alignment. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareAndSwapUint32 ¶
func (o MemoryOrder) CompareAndSwapUint32(addr *uint32, old, new uint32) (swapped bool)
CompareAndSwapUint32 atomically compares *addr with old and swaps if equal. Returns true if the swap was performed. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareAndSwapUint64 ¶
func (o MemoryOrder) CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool)
CompareAndSwapUint64 atomically compares *addr with old and swaps if equal. Returns true if the swap was performed. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareAndSwapUintptr ¶
func (o MemoryOrder) CompareAndSwapUintptr(addr *uintptr, old, new uintptr) (swapped bool)
CompareAndSwapUintptr atomically compares *addr with old and swaps if equal. Returns true if the swap was performed. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareExchangeInt128 ¶
func (o MemoryOrder) CompareExchangeInt128(addr *Int128, oldLo, oldHi, newLo, newHi int64) (prevLo, prevHi int64)
CompareExchangeInt128 atomically compares *addr with (oldLo, oldHi) and swaps if equal. Returns the previous value (enables CAS loops without separate Load). addr MUST be 16-byte aligned; use PlaceAlignedInt128 to ensure alignment. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareExchangeInt32 ¶
func (o MemoryOrder) CompareExchangeInt32(addr *int32, old, new int32) (prev int32)
CompareExchangeInt32 atomically compares *addr with old and swaps if equal. Returns the previous value (enables CAS loops without separate Load). Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareExchangeInt64 ¶
func (o MemoryOrder) CompareExchangeInt64(addr *int64, old, new int64) (prev int64)
CompareExchangeInt64 atomically compares *addr with old and swaps if equal. Returns the previous value (enables CAS loops without separate Load). Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareExchangePointer ¶
func (o MemoryOrder) CompareExchangePointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (prev unsafe.Pointer)
CompareExchangePointer atomically compares *addr with old and swaps if equal. Returns the previous value (enables CAS loops without separate Load). Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareExchangeUint128 ¶
func (o MemoryOrder) CompareExchangeUint128(addr *Uint128, oldLo, oldHi, newLo, newHi uint64) (prevLo, prevHi uint64)
CompareExchangeUint128 atomically compares *addr with (oldLo, oldHi) and swaps if equal. Returns the previous value (enables CAS loops without separate Load). addr MUST be 16-byte aligned; use PlaceAlignedUint128 to ensure alignment. Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareExchangeUint32 ¶
func (o MemoryOrder) CompareExchangeUint32(addr *uint32, old, new uint32) (prev uint32)
CompareExchangeUint32 atomically compares *addr with old and swaps if equal. Returns the previous value (enables CAS loops without separate Load). Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareExchangeUint64 ¶
func (o MemoryOrder) CompareExchangeUint64(addr *uint64, old, new uint64) (prev uint64)
CompareExchangeUint64 atomically compares *addr with old and swaps if equal. Returns the previous value (enables CAS loops without separate Load). Unknown orderings fallback to AcqRel.
func (MemoryOrder) CompareExchangeUintptr ¶
func (o MemoryOrder) CompareExchangeUintptr(addr *uintptr, old, new uintptr) (prev uintptr)
CompareExchangeUintptr atomically compares *addr with old and swaps if equal. Returns the previous value (enables CAS loops without separate Load). Unknown orderings fallback to AcqRel.
func (MemoryOrder) LoadBool ¶
func (o MemoryOrder) LoadBool(addr *uint32) bool
LoadBool atomically loads *addr with the specified memory ordering. addr points to a uint32 where 0 is false and non-zero is true. Unknown orderings fallback to Acquire.
func (MemoryOrder) LoadInt128 ¶
func (o MemoryOrder) LoadInt128(addr *Int128) (lo, hi int64)
LoadInt128 atomically loads *addr with the specified memory ordering. Returns (lo, hi) where the full value is (hi << 64) | lo. addr MUST be 16-byte aligned; use PlaceAlignedInt128 to ensure alignment. Unknown orderings fallback to Acquire.
func (MemoryOrder) LoadInt32 ¶
func (o MemoryOrder) LoadInt32(addr *int32) int32
LoadInt32 atomically loads *addr with the specified memory ordering. Unknown orderings fallback to Acquire.
func (MemoryOrder) LoadInt64 ¶
func (o MemoryOrder) LoadInt64(addr *int64) int64
LoadInt64 atomically loads *addr with the specified memory ordering. Unknown orderings fallback to Acquire.
func (MemoryOrder) LoadPointer ¶
func (o MemoryOrder) LoadPointer(addr *unsafe.Pointer) unsafe.Pointer
LoadPointer atomically loads *addr with the specified memory ordering. Unknown orderings fallback to Acquire.
func (MemoryOrder) LoadUint128 ¶
func (o MemoryOrder) LoadUint128(addr *Uint128) (lo, hi uint64)
LoadUint128 atomically loads *addr with the specified memory ordering. Returns (lo, hi) where the full value is (hi << 64) | lo. addr MUST be 16-byte aligned; use PlaceAlignedUint128 to ensure alignment. Unknown orderings fallback to Acquire.
func (MemoryOrder) LoadUint32 ¶
func (o MemoryOrder) LoadUint32(addr *uint32) uint32
LoadUint32 atomically loads *addr with the specified memory ordering. Unknown orderings fallback to Acquire.
func (MemoryOrder) LoadUint64 ¶
func (o MemoryOrder) LoadUint64(addr *uint64) uint64
LoadUint64 atomically loads *addr with the specified memory ordering. Unknown orderings fallback to Acquire.
func (MemoryOrder) LoadUintptr ¶
func (o MemoryOrder) LoadUintptr(addr *uintptr) uintptr
LoadUintptr atomically loads *addr with the specified memory ordering. Unknown orderings fallback to Acquire.
func (MemoryOrder) MaxInt32 ¶
func (o MemoryOrder) MaxInt32(addr *int32, val int32) (old int32)
MaxInt32 atomically stores max(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) MaxInt64 ¶
func (o MemoryOrder) MaxInt64(addr *int64, val int64) (old int64)
MaxInt64 atomically stores max(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) MaxUint32 ¶
func (o MemoryOrder) MaxUint32(addr *uint32, val uint32) (old uint32)
MaxUint32 atomically stores max(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) MaxUint64 ¶
func (o MemoryOrder) MaxUint64(addr *uint64, val uint64) (old uint64)
MaxUint64 atomically stores max(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) MaxUintptr ¶
func (o MemoryOrder) MaxUintptr(addr *uintptr, val uintptr) (old uintptr)
MaxUintptr atomically stores max(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) MinInt32 ¶
func (o MemoryOrder) MinInt32(addr *int32, val int32) (old int32)
MinInt32 atomically stores min(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) MinInt64 ¶
func (o MemoryOrder) MinInt64(addr *int64, val int64) (old int64)
MinInt64 atomically stores min(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) MinUint32 ¶
func (o MemoryOrder) MinUint32(addr *uint32, val uint32) (old uint32)
MinUint32 atomically stores min(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) MinUint64 ¶
func (o MemoryOrder) MinUint64(addr *uint64, val uint64) (old uint64)
MinUint64 atomically stores min(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) MinUintptr ¶
func (o MemoryOrder) MinUintptr(addr *uintptr, val uintptr) (old uintptr)
MinUintptr atomically stores min(*addr, val) and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) OrInt32 ¶
func (o MemoryOrder) OrInt32(addr *int32, mask int32) (old int32)
OrInt32 atomically performs *addr |= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) OrInt64 ¶
func (o MemoryOrder) OrInt64(addr *int64, mask int64) (old int64)
OrInt64 atomically performs *addr |= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) OrUint32 ¶
func (o MemoryOrder) OrUint32(addr *uint32, mask uint32) (old uint32)
OrUint32 atomically performs *addr |= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) OrUint64 ¶
func (o MemoryOrder) OrUint64(addr *uint64, mask uint64) (old uint64)
OrUint64 atomically performs *addr |= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) OrUintptr ¶
func (o MemoryOrder) OrUintptr(addr *uintptr, mask uintptr) (old uintptr)
OrUintptr atomically performs *addr |= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) StoreBool ¶
func (o MemoryOrder) StoreBool(addr *uint32, val bool)
StoreBool atomically stores val to *addr with the specified memory ordering. addr points to a uint32 where 0 is false and 1 is true. Unknown orderings fallback to Release.
func (MemoryOrder) StoreInt128 ¶
func (o MemoryOrder) StoreInt128(addr *Int128, lo, hi int64)
StoreInt128 atomically stores (lo, hi) to *addr with the specified memory ordering. addr MUST be 16-byte aligned; use PlaceAlignedInt128 to ensure alignment. Unknown orderings fallback to Release.
func (MemoryOrder) StoreInt32 ¶
func (o MemoryOrder) StoreInt32(addr *int32, val int32)
StoreInt32 atomically stores val to *addr with the specified memory ordering. Unknown orderings fallback to Release.
func (MemoryOrder) StoreInt64 ¶
func (o MemoryOrder) StoreInt64(addr *int64, val int64)
StoreInt64 atomically stores val to *addr with the specified memory ordering. Unknown orderings fallback to Release.
func (MemoryOrder) StorePointer ¶
func (o MemoryOrder) StorePointer(addr *unsafe.Pointer, val unsafe.Pointer)
StorePointer atomically stores val to *addr with the specified memory ordering. Unknown orderings fallback to Release.
func (MemoryOrder) StoreUint128 ¶
func (o MemoryOrder) StoreUint128(addr *Uint128, lo, hi uint64)
StoreUint128 atomically stores (lo, hi) to *addr with the specified memory ordering. addr MUST be 16-byte aligned; use PlaceAlignedUint128 to ensure alignment. Unknown orderings fallback to Release.
func (MemoryOrder) StoreUint32 ¶
func (o MemoryOrder) StoreUint32(addr *uint32, val uint32)
StoreUint32 atomically stores val to *addr with the specified memory ordering. Unknown orderings fallback to Release.
func (MemoryOrder) StoreUint64 ¶
func (o MemoryOrder) StoreUint64(addr *uint64, val uint64)
StoreUint64 atomically stores val to *addr with the specified memory ordering. Unknown orderings fallback to Release.
func (MemoryOrder) StoreUintptr ¶
func (o MemoryOrder) StoreUintptr(addr *uintptr, val uintptr)
StoreUintptr atomically stores val to *addr with the specified memory ordering. Unknown orderings fallback to Release.
func (MemoryOrder) SwapBool ¶
func (o MemoryOrder) SwapBool(addr *uint32, new bool) (old bool)
SwapBool atomically stores new to *addr and returns the old value. addr points to a uint32 where 0 is false and non-zero is true. Unknown orderings fallback to AcqRel.
func (MemoryOrder) SwapInt128 ¶
func (o MemoryOrder) SwapInt128(addr *Int128, newLo, newHi int64) (oldLo, oldHi int64)
SwapInt128 atomically stores (newLo, newHi) to *addr and returns the old value. addr MUST be 16-byte aligned; use PlaceAlignedInt128 to ensure alignment. Unknown orderings fallback to AcqRel.
func (MemoryOrder) SwapInt32 ¶
func (o MemoryOrder) SwapInt32(addr *int32, new int32) (old int32)
SwapInt32 atomically stores new to *addr and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) SwapInt64 ¶
func (o MemoryOrder) SwapInt64(addr *int64, new int64) (old int64)
SwapInt64 atomically stores new to *addr and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) SwapPointer ¶
SwapPointer atomically stores new to *addr and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) SwapUint128 ¶
func (o MemoryOrder) SwapUint128(addr *Uint128, newLo, newHi uint64) (oldLo, oldHi uint64)
SwapUint128 atomically stores (newLo, newHi) to *addr and returns the old value. addr MUST be 16-byte aligned; use PlaceAlignedUint128 to ensure alignment. Unknown orderings fallback to AcqRel.
func (MemoryOrder) SwapUint32 ¶
func (o MemoryOrder) SwapUint32(addr *uint32, new uint32) (old uint32)
SwapUint32 atomically stores new to *addr and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) SwapUint64 ¶
func (o MemoryOrder) SwapUint64(addr *uint64, new uint64) (old uint64)
SwapUint64 atomically stores new to *addr and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) SwapUintptr ¶
func (o MemoryOrder) SwapUintptr(addr *uintptr, new uintptr) (old uintptr)
SwapUintptr atomically stores new to *addr and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) XorInt32 ¶
func (o MemoryOrder) XorInt32(addr *int32, mask int32) (old int32)
XorInt32 atomically performs *addr ^= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) XorInt64 ¶
func (o MemoryOrder) XorInt64(addr *int64, mask int64) (old int64)
XorInt64 atomically performs *addr ^= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) XorUint32 ¶
func (o MemoryOrder) XorUint32(addr *uint32, mask uint32) (old uint32)
XorUint32 atomically performs *addr ^= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) XorUint64 ¶
func (o MemoryOrder) XorUint64(addr *uint64, mask uint64) (old uint64)
XorUint64 atomically performs *addr ^= mask and returns the old value. Unknown orderings fallback to AcqRel.
func (MemoryOrder) XorUintptr ¶
func (o MemoryOrder) XorUintptr(addr *uintptr, mask uintptr) (old uintptr)
XorUintptr atomically performs *addr ^= mask and returns the old value. Unknown orderings fallback to AcqRel.
type Pointer ¶
type Pointer[T any] struct { // contains filtered or unexported fields }
Pointer represents an atomic pointer to a value of type T.
The zero value is nil. Pointer is safe for concurrent use. Must not be copied after first use.
func (*Pointer[T]) CompareAndSwap ¶
CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.
func (*Pointer[T]) CompareAndSwapAcqRel ¶
CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.
func (*Pointer[T]) CompareAndSwapAcquire ¶
CompareAndSwapAcquire atomically compares and swaps with acquire ordering.
func (*Pointer[T]) CompareAndSwapRelaxed ¶
CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.
func (*Pointer[T]) CompareAndSwapRelease ¶
CompareAndSwapRelease atomically compares and swaps with release ordering.
func (*Pointer[T]) CompareExchange ¶
func (a *Pointer[T]) CompareExchange(old, new *T) *T
CompareExchange atomically compares and swaps, returning the old pointer. Uses acquire-release ordering.
func (*Pointer[T]) CompareExchangeAcqRel ¶
func (a *Pointer[T]) CompareExchangeAcqRel(old, new *T) *T
CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.
func (*Pointer[T]) CompareExchangeAcquire ¶
func (a *Pointer[T]) CompareExchangeAcquire(old, new *T) *T
CompareExchangeAcquire atomically compares and swaps with acquire ordering.
func (*Pointer[T]) CompareExchangeRelaxed ¶
func (a *Pointer[T]) CompareExchangeRelaxed(old, new *T) *T
CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.
func (*Pointer[T]) CompareExchangeRelease ¶
func (a *Pointer[T]) CompareExchangeRelease(old, new *T) *T
CompareExchangeRelease atomically compares and swaps with release ordering.
func (*Pointer[T]) Load ¶
func (a *Pointer[T]) Load() *T
Load atomically loads and returns the pointer with relaxed ordering.
func (*Pointer[T]) LoadAcquire ¶
func (a *Pointer[T]) LoadAcquire() *T
LoadAcquire atomically loads and returns the pointer with acquire ordering.
func (*Pointer[T]) LoadRelaxed ¶
func (a *Pointer[T]) LoadRelaxed() *T
LoadRelaxed atomically loads and returns the pointer with relaxed ordering.
func (*Pointer[T]) Store ¶
func (a *Pointer[T]) Store(val *T)
Store atomically stores val with relaxed ordering.
func (*Pointer[T]) StoreRelaxed ¶
func (a *Pointer[T]) StoreRelaxed(val *T)
StoreRelaxed atomically stores val with relaxed ordering.
func (*Pointer[T]) StoreRelease ¶
func (a *Pointer[T]) StoreRelease(val *T)
StoreRelease atomically stores val with release ordering.
func (*Pointer[T]) Swap ¶
func (a *Pointer[T]) Swap(new *T) *T
Swap atomically swaps the pointer and returns the old value with acquire-release ordering.
func (*Pointer[T]) SwapAcqRel ¶
func (a *Pointer[T]) SwapAcqRel(new *T) *T
SwapAcqRel atomically swaps the pointer with acquire-release ordering.
func (*Pointer[T]) SwapAcquire ¶
func (a *Pointer[T]) SwapAcquire(new *T) *T
SwapAcquire atomically swaps the pointer with acquire ordering.
func (*Pointer[T]) SwapRelaxed ¶
func (a *Pointer[T]) SwapRelaxed(new *T) *T
SwapRelaxed atomically swaps the pointer with relaxed ordering.
func (*Pointer[T]) SwapRelease ¶
func (a *Pointer[T]) SwapRelease(new *T) *T
SwapRelease atomically swaps the pointer with release ordering.
type Uint128 ¶
type Uint128 struct {
// contains filtered or unexported fields
}
Uint128 represents an atomic 128-bit unsigned integer.
The zero value is 0. Uint128 is safe for concurrent use. Must not be copied after first use.
Uint128 requires 16-byte alignment. Use PlaceAlignedUint128 to ensure proper alignment when embedding in byte slices or shared memory.
func PlaceAlignedUint128 ¶
PlaceAlignedUint128 places a Uint128 at a 16-byte aligned address in p.
func (*Uint128) Add ¶
Add atomically adds (deltaLo, deltaHi) and returns the new value. Uses acquire-release ordering.
func (*Uint128) AddRelaxed ¶
AddRelaxed atomically adds (deltaLo, deltaHi) and returns the new value.
func (*Uint128) CompareAndSwap ¶
CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.
func (*Uint128) CompareAndSwapAcqRel ¶
CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.
func (*Uint128) CompareAndSwapAcquire ¶
CompareAndSwapAcquire atomically compares and swaps with acquire ordering.
func (*Uint128) CompareAndSwapRelaxed ¶
CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.
func (*Uint128) CompareAndSwapRelease ¶
CompareAndSwapRelease atomically compares and swaps with release ordering.
func (*Uint128) CompareExchange ¶
CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.
func (*Uint128) CompareExchangeAcqRel ¶
CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.
func (*Uint128) CompareExchangeAcquire ¶
CompareExchangeAcquire atomically compares and swaps with acquire ordering.
func (*Uint128) CompareExchangeRelaxed ¶
CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.
func (*Uint128) CompareExchangeRelease ¶
CompareExchangeRelease atomically compares and swaps with release ordering.
func (*Uint128) Dec ¶
Dec atomically decrements by 1 and returns the new value. Uses acquire-release ordering.
func (*Uint128) DecRelaxed ¶
DecRelaxed atomically decrements by 1 and returns the new value.
func (*Uint128) EqualRelaxed ¶
EqualRelaxed atomically loads and compares with relaxed ordering.
func (*Uint128) Greater ¶
Greater atomically loads and returns true if value > (lo, hi). Uses acquire ordering.
func (*Uint128) GreaterOrEqual ¶
GreaterOrEqual atomically loads and returns true if value >= (lo, hi). Uses acquire ordering.
func (*Uint128) GreaterOrEqualRelaxed ¶
GreaterOrEqualRelaxed atomically loads and compares with relaxed ordering.
func (*Uint128) GreaterRelaxed ¶
GreaterRelaxed atomically loads and compares with relaxed ordering.
func (*Uint128) Inc ¶
Inc atomically increments by 1 and returns the new value. Uses acquire-release ordering.
func (*Uint128) IncRelaxed ¶
IncRelaxed atomically increments by 1 and returns the new value.
func (*Uint128) Less ¶
Less atomically loads and returns true if value < (lo, hi). Uses acquire ordering.
func (*Uint128) LessOrEqual ¶
LessOrEqual atomically loads and returns true if value <= (lo, hi). Uses acquire ordering.
func (*Uint128) LessOrEqualRelaxed ¶
LessOrEqualRelaxed atomically loads and compares with relaxed ordering.
func (*Uint128) LessRelaxed ¶
LessRelaxed atomically loads and compares with relaxed ordering.
func (*Uint128) LoadAcquire ¶
LoadAcquire atomically loads and returns the value with acquire ordering.
func (*Uint128) LoadRelaxed ¶
LoadRelaxed atomically loads and returns the value with relaxed ordering.
func (*Uint128) StoreRelaxed ¶
StoreRelaxed atomically stores val with relaxed ordering.
func (*Uint128) StoreRelease ¶
StoreRelease atomically stores val with release ordering.
func (*Uint128) Sub ¶
Sub atomically subtracts (deltaLo, deltaHi) and returns the new value. Uses acquire-release ordering.
func (*Uint128) SubRelaxed ¶
SubRelaxed atomically subtracts (deltaLo, deltaHi) and returns the new value.
func (*Uint128) Swap ¶
Swap atomically stores new value and returns the old value. Uses acquire-release ordering.
func (*Uint128) SwapAcqRel ¶
SwapAcqRel atomically stores new value and returns the old value with acquire-release ordering.
func (*Uint128) SwapAcquire ¶
SwapAcquire atomically stores new value and returns the old value with acquire ordering.
func (*Uint128) SwapRelaxed ¶
SwapRelaxed atomically stores new value and returns the old value with relaxed ordering.
func (*Uint128) SwapRelease ¶
SwapRelease atomically stores new value and returns the old value with release ordering.
type Uint128Padded ¶
type Uint128Padded struct {
Uint128
// contains filtered or unexported fields
}
Uint128Padded is a Uint128 padded to cache line size.
func PlaceCacheAlignedUint128 ¶
func PlaceCacheAlignedUint128(p []byte, off int) (n int, a *Uint128Padded)
PlaceCacheAlignedUint128 places a Uint128Padded at a cache-line aligned address.
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 represents an atomic 32-bit unsigned integer.
The zero value is 0. Uint32 is safe for concurrent use. Must not be copied after first use.
func PlaceAlignedUint32 ¶
PlaceAlignedUint32 places a Uint32 at a 4-byte aligned address in p.
func (*Uint32) Add ¶
Add atomically adds delta and returns the new value with acquire-release ordering.
func (*Uint32) AddAcqRel ¶
AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.
func (*Uint32) AddAcquire ¶
AddAcquire atomically adds delta and returns the new value with acquire ordering.
func (*Uint32) AddRelaxed ¶
AddRelaxed atomically adds delta and returns the new value with relaxed ordering.
func (*Uint32) AddRelease ¶
AddRelease atomically adds delta and returns the new value with release ordering.
func (*Uint32) And ¶
And atomically performs bitwise AND and returns the old value with acquire-release ordering.
func (*Uint32) AndAcquire ¶
AndAcquire atomically performs bitwise AND with acquire ordering.
func (*Uint32) AndRelaxed ¶
AndRelaxed atomically performs bitwise AND with relaxed ordering.
func (*Uint32) AndRelease ¶
AndRelease atomically performs bitwise AND with release ordering.
func (*Uint32) CompareAndSwap ¶
CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.
func (*Uint32) CompareAndSwapAcqRel ¶
CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.
func (*Uint32) CompareAndSwapAcquire ¶
CompareAndSwapAcquire atomically compares and swaps with acquire ordering.
func (*Uint32) CompareAndSwapRelaxed ¶
CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.
func (*Uint32) CompareAndSwapRelease ¶
CompareAndSwapRelease atomically compares and swaps with release ordering.
func (*Uint32) CompareExchange ¶
CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.
func (*Uint32) CompareExchangeAcqRel ¶
CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.
func (*Uint32) CompareExchangeAcquire ¶
CompareExchangeAcquire atomically compares and swaps with acquire ordering.
func (*Uint32) CompareExchangeRelaxed ¶
CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.
func (*Uint32) CompareExchangeRelease ¶
CompareExchangeRelease atomically compares and swaps with release ordering.
func (*Uint32) LoadAcquire ¶
LoadAcquire atomically loads and returns the value with acquire ordering.
func (*Uint32) LoadRelaxed ¶
LoadRelaxed atomically loads and returns the value with relaxed ordering.
func (*Uint32) Max ¶
Max atomically stores the maximum of current and val, returning the old value. Uses acquire-release ordering.
func (*Uint32) MaxRelaxed ¶
MaxRelaxed atomically stores the maximum with relaxed ordering.
func (*Uint32) Min ¶
Min atomically stores the minimum of current and val, returning the old value. Uses acquire-release ordering.
func (*Uint32) MinRelaxed ¶
MinRelaxed atomically stores the minimum with relaxed ordering.
func (*Uint32) Or ¶
Or atomically performs bitwise OR and returns the old value with acquire-release ordering.
func (*Uint32) StoreRelaxed ¶
StoreRelaxed atomically stores val with relaxed ordering.
func (*Uint32) StoreRelease ¶
StoreRelease atomically stores val with release ordering.
func (*Uint32) Sub ¶
Sub atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Uint32) SubAcqRel ¶
SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Uint32) SubAcquire ¶
SubAcquire atomically subtracts delta and returns the new value with acquire ordering.
func (*Uint32) SubRelaxed ¶
SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.
func (*Uint32) SubRelease ¶
SubRelease atomically subtracts delta and returns the new value with release ordering.
func (*Uint32) Swap ¶
Swap atomically swaps the value and returns the old value with acquire-release ordering.
func (*Uint32) SwapAcqRel ¶
SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.
func (*Uint32) SwapAcquire ¶
SwapAcquire atomically swaps the value and returns the old value with acquire ordering.
func (*Uint32) SwapRelaxed ¶
SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.
func (*Uint32) SwapRelease ¶
SwapRelease atomically swaps the value and returns the old value with release ordering.
func (*Uint32) Xor ¶
Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.
func (*Uint32) XorAcquire ¶
XorAcquire atomically performs bitwise XOR with acquire ordering.
func (*Uint32) XorRelaxed ¶
XorRelaxed atomically performs bitwise XOR with relaxed ordering.
func (*Uint32) XorRelease ¶
XorRelease atomically performs bitwise XOR with release ordering.
type Uint32Padded ¶
type Uint32Padded struct {
Uint32
// contains filtered or unexported fields
}
Uint32Padded is a Uint32 padded to cache line size.
func PlaceCacheAlignedUint32 ¶
func PlaceCacheAlignedUint32(p []byte, off int) (n int, a *Uint32Padded)
PlaceCacheAlignedUint32 places a Uint32Padded at a cache-line aligned address.
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
Uint64 represents an atomic 64-bit unsigned integer.
The zero value is 0. Uint64 is safe for concurrent use. Must not be copied after first use.
func PlaceAlignedUint64 ¶
PlaceAlignedUint64 places a Uint64 at an 8-byte aligned address in p.
func (*Uint64) Add ¶
Add atomically adds delta and returns the new value with acquire-release ordering.
func (*Uint64) AddAcqRel ¶
AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.
func (*Uint64) AddAcquire ¶
AddAcquire atomically adds delta and returns the new value with acquire ordering.
func (*Uint64) AddRelaxed ¶
AddRelaxed atomically adds delta and returns the new value with relaxed ordering.
func (*Uint64) AddRelease ¶
AddRelease atomically adds delta and returns the new value with release ordering.
func (*Uint64) And ¶
And atomically performs bitwise AND and returns the old value with acquire-release ordering.
func (*Uint64) AndAcquire ¶
AndAcquire atomically performs bitwise AND with acquire ordering.
func (*Uint64) AndRelaxed ¶
AndRelaxed atomically performs bitwise AND with relaxed ordering.
func (*Uint64) AndRelease ¶
AndRelease atomically performs bitwise AND with release ordering.
func (*Uint64) CompareAndSwap ¶
CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.
func (*Uint64) CompareAndSwapAcqRel ¶
CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.
func (*Uint64) CompareAndSwapAcquire ¶
CompareAndSwapAcquire atomically compares and swaps with acquire ordering.
func (*Uint64) CompareAndSwapRelaxed ¶
CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.
func (*Uint64) CompareAndSwapRelease ¶
CompareAndSwapRelease atomically compares and swaps with release ordering.
func (*Uint64) CompareExchange ¶
CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.
func (*Uint64) CompareExchangeAcqRel ¶
CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.
func (*Uint64) CompareExchangeAcquire ¶
CompareExchangeAcquire atomically compares and swaps with acquire ordering.
func (*Uint64) CompareExchangeRelaxed ¶
CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.
func (*Uint64) CompareExchangeRelease ¶
CompareExchangeRelease atomically compares and swaps with release ordering.
func (*Uint64) LoadAcquire ¶
LoadAcquire atomically loads and returns the value with acquire ordering.
func (*Uint64) LoadRelaxed ¶
LoadRelaxed atomically loads and returns the value with relaxed ordering.
func (*Uint64) Max ¶
Max atomically stores the maximum of current and val, returning the old value. Uses acquire-release ordering.
func (*Uint64) MaxRelaxed ¶
MaxRelaxed atomically stores the maximum with relaxed ordering.
func (*Uint64) Min ¶
Min atomically stores the minimum of current and val, returning the old value. Uses acquire-release ordering.
func (*Uint64) MinRelaxed ¶
MinRelaxed atomically stores the minimum with relaxed ordering.
func (*Uint64) Or ¶
Or atomically performs bitwise OR and returns the old value with acquire-release ordering.
func (*Uint64) StoreRelaxed ¶
StoreRelaxed atomically stores val with relaxed ordering.
func (*Uint64) StoreRelease ¶
StoreRelease atomically stores val with release ordering.
func (*Uint64) Sub ¶
Sub atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Uint64) SubAcqRel ¶
SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Uint64) SubAcquire ¶
SubAcquire atomically subtracts delta and returns the new value with acquire ordering.
func (*Uint64) SubRelaxed ¶
SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.
func (*Uint64) SubRelease ¶
SubRelease atomically subtracts delta and returns the new value with release ordering.
func (*Uint64) Swap ¶
Swap atomically swaps the value and returns the old value with acquire-release ordering.
func (*Uint64) SwapAcqRel ¶
SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.
func (*Uint64) SwapAcquire ¶
SwapAcquire atomically swaps the value and returns the old value with acquire ordering.
func (*Uint64) SwapRelaxed ¶
SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.
func (*Uint64) SwapRelease ¶
SwapRelease atomically swaps the value and returns the old value with release ordering.
func (*Uint64) Xor ¶
Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.
func (*Uint64) XorAcquire ¶
XorAcquire atomically performs bitwise XOR with acquire ordering.
func (*Uint64) XorRelaxed ¶
XorRelaxed atomically performs bitwise XOR with relaxed ordering.
func (*Uint64) XorRelease ¶
XorRelease atomically performs bitwise XOR with release ordering.
type Uint64Padded ¶
type Uint64Padded struct {
Uint64
// contains filtered or unexported fields
}
Uint64Padded is a Uint64 padded to cache line size.
func PlaceCacheAlignedUint64 ¶
func PlaceCacheAlignedUint64(p []byte, off int) (n int, a *Uint64Padded)
PlaceCacheAlignedUint64 places a Uint64Padded at a cache-line aligned address.
type Uintptr ¶
type Uintptr struct {
// contains filtered or unexported fields
}
Uintptr represents an atomic pointer-sized unsigned integer.
The zero value is 0. Uintptr is safe for concurrent use. Must not be copied after first use.
func PlaceAlignedUintptr ¶
PlaceAlignedUintptr places a Uintptr at a pointer-aligned address in p.
func (*Uintptr) Add ¶
Add atomically adds delta and returns the new value with acquire-release ordering.
func (*Uintptr) AddAcqRel ¶
AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.
func (*Uintptr) AddAcquire ¶
AddAcquire atomically adds delta and returns the new value with acquire ordering.
func (*Uintptr) AddRelaxed ¶
AddRelaxed atomically adds delta and returns the new value with relaxed ordering.
func (*Uintptr) AddRelease ¶
AddRelease atomically adds delta and returns the new value with release ordering.
func (*Uintptr) And ¶
And atomically performs bitwise AND and returns the old value with acquire-release ordering.
func (*Uintptr) AndAcqRel ¶
AndAcqRel atomically performs bitwise AND with acquire-release ordering.
func (*Uintptr) AndAcquire ¶
AndAcquire atomically performs bitwise AND with acquire ordering.
func (*Uintptr) AndRelaxed ¶
AndRelaxed atomically performs bitwise AND with relaxed ordering.
func (*Uintptr) AndRelease ¶
AndRelease atomically performs bitwise AND with release ordering.
func (*Uintptr) CompareAndSwap ¶
CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.
func (*Uintptr) CompareAndSwapAcqRel ¶
CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.
func (*Uintptr) CompareAndSwapAcquire ¶
CompareAndSwapAcquire atomically compares and swaps with acquire ordering.
func (*Uintptr) CompareAndSwapRelaxed ¶
CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.
func (*Uintptr) CompareAndSwapRelease ¶
CompareAndSwapRelease atomically compares and swaps with release ordering.
func (*Uintptr) CompareExchange ¶
CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.
func (*Uintptr) CompareExchangeAcqRel ¶
CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.
func (*Uintptr) CompareExchangeAcquire ¶
CompareExchangeAcquire atomically compares and swaps with acquire ordering.
func (*Uintptr) CompareExchangeRelaxed ¶
CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.
func (*Uintptr) CompareExchangeRelease ¶
CompareExchangeRelease atomically compares and swaps with release ordering.
func (*Uintptr) LoadAcquire ¶
LoadAcquire atomically loads and returns the value with acquire ordering.
func (*Uintptr) LoadRelaxed ¶
LoadRelaxed atomically loads and returns the value with relaxed ordering.
func (*Uintptr) Max ¶
Max atomically stores max(*addr, val) and returns the old value with acquire-release ordering.
func (*Uintptr) MaxRelaxed ¶
MaxRelaxed atomically stores max(*addr, val) and returns the old value with relaxed ordering.
func (*Uintptr) Min ¶
Min atomically stores min(*addr, val) and returns the old value with acquire-release ordering.
func (*Uintptr) MinRelaxed ¶
MinRelaxed atomically stores min(*addr, val) and returns the old value with relaxed ordering.
func (*Uintptr) Or ¶
Or atomically performs bitwise OR and returns the old value with acquire-release ordering.
func (*Uintptr) StoreRelaxed ¶
StoreRelaxed atomically stores val with relaxed ordering.
func (*Uintptr) StoreRelease ¶
StoreRelease atomically stores val with release ordering.
func (*Uintptr) Sub ¶
Sub atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Uintptr) SubAcqRel ¶
SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.
func (*Uintptr) SubAcquire ¶
SubAcquire atomically subtracts delta and returns the new value with acquire ordering.
func (*Uintptr) SubRelaxed ¶
SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.
func (*Uintptr) SubRelease ¶
SubRelease atomically subtracts delta and returns the new value with release ordering.
func (*Uintptr) Swap ¶
Swap atomically swaps the value and returns the old value with acquire-release ordering.
func (*Uintptr) SwapAcqRel ¶
SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.
func (*Uintptr) SwapAcquire ¶
SwapAcquire atomically swaps the value and returns the old value with acquire ordering.
func (*Uintptr) SwapRelaxed ¶
SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.
func (*Uintptr) SwapRelease ¶
SwapRelease atomically swaps the value and returns the old value with release ordering.
func (*Uintptr) Xor ¶
Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.
func (*Uintptr) XorAcqRel ¶
XorAcqRel atomically performs bitwise XOR with acquire-release ordering.
func (*Uintptr) XorAcquire ¶
XorAcquire atomically performs bitwise XOR with acquire ordering.
func (*Uintptr) XorRelaxed ¶
XorRelaxed atomically performs bitwise XOR with relaxed ordering.
func (*Uintptr) XorRelease ¶
XorRelease atomically performs bitwise XOR with release ordering.
type UintptrPadded ¶
type UintptrPadded struct {
Uintptr
// contains filtered or unexported fields
}
UintptrPadded is a Uintptr padded to cache line size.
func PlaceCacheAlignedUintptr ¶
func PlaceCacheAlignedUintptr(p []byte, off int) (n int, a *UintptrPadded)
PlaceCacheAlignedUintptr places a UintptrPadded at a cache-line aligned address.