atomix

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 2 Imported by: 0

README

atomix

Go Reference Go Report Card Codecov

Languages: English | 简体中文 | 日本語 | Español | Français

Atomic operations with explicit memory ordering for Go.

Overview

Go's sync/atomic provides atomic operations with sequential consistency. This library exposes C++11/C11 memory model orderings (Relaxed, Acquire, Release, AcqRel) through architecture-specific implementations.

import "code.hybscloud.com/atomix"

var counter atomix.Int64

// Method-based API with ordering suffix
counter.AddRelaxed(1)    // Relaxed: no synchronization
counter.Add(1)           // AcqRel: default safe ordering

// Pointer-based API for raw memory
var flags int32
atomix.Relaxed.StoreInt32(&flags, 1)
val := atomix.Acquire.LoadInt32(&flags)

Installation

go get code.hybscloud.com/atomix

Requirements: Go 1.25+

Memory Ordering

The library implements four orderings from the C++11 memory model:

Ordering Semantics
Relaxed Atomicity only. No synchronization or ordering constraints.
Acquire Subsequent reads/writes cannot be reordered before this load. Pairs with Release stores.
Release Prior reads/writes cannot be reordered after this store. Pairs with Acquire loads.
AcqRel Combines Acquire and Release semantics. For read-modify-write operations.
Ordering Selection

Default methods (no ordering suffix) use:

  • Load operations: Relaxed
  • Store operations: Relaxed
  • Read-modify-write operations: AcqRel

Note: sync/atomic uses acquire for Load and release for Store (sequential consistency on x86). atomix defaults to Relaxed for maximum performance on weakly-ordered architectures. Use LoadAcquire/StoreRelease when sync/atomic-equivalent ordering is required.

When to Use Each Ordering
Use Case Ordering Rationale
Statistics counters Relaxed No synchronization needed; eventual consistency acceptable
Reference counting AcqRel Ensures visibility of object state before deallocation
Producer-consumer flags Release/Acquire Producer releases data, consumer acquires
Spinlock acquire Acquire Critical section reads must see prior writes
Spinlock release Release Critical section writes must complete before unlock
Sequence locks AcqRel Both directions need ordering

Types

Value Types
Type Size Description
Bool 4 bytes Atomic boolean (backed by uint32)
Int32, Uint32 4 bytes 32-bit integers
Int64, Uint64 8 bytes 64-bit integers
Uintptr 8 bytes Pointer-sized integer
Pointer[T] 8 bytes Generic atomic pointer
Int128, Uint128 16 bytes 128-bit integers (requires 16-byte alignment)
Padded Types

Padded variants (Int64Padded, Uint64Padded, etc.) occupy a full cache line (64 bytes) to prevent false sharing when multiple atomic variables are accessed by different CPU cores.

// Without padding: variables may share cache line, causing contention
var a, b atomix.Int64  // May be adjacent in memory

// With padding: each variable occupies its own cache line
var a, b atomix.Int64Padded  // 64-byte separation guaranteed

Operations

Operation Returns Description
Load value Atomic read
Store Atomic write
Swap old value Atomic exchange
CompareAndSwap bool Returns true if exchange occurred
CompareExchange old value Returns previous value regardless of success
Add, Sub new value Atomic arithmetic
Inc, Dec new value Atomic increment/decrement by 1
And, Or, Xor old value Atomic bitwise operations
Max, Min old value Atomic maximum/minimum

Return value semantics: Add/Sub/Inc/Dec return the new value (like sync/atomic). Swap/And/Or/Xor/Max/Min return the old value.

CompareAndSwap vs CompareExchange
// CompareAndSwap: returns success/failure
if v.CompareAndSwap(old, new) {
    // Success
}

// CompareExchange: returns previous value (enables CAS loops without separate Load)
for {
    old := v.Load()
    new := transform(old)
    if v.CompareExchange(old, new) == old {
        break  // Success
    }
}

Pointer-Based API

For interoperation with memory-mapped regions, shared memory, or io_uring rings:

var flags int32

atomix.Relaxed.StoreInt32(&flags, 1)
val := atomix.Acquire.LoadInt32(&flags)
atomix.Release.CompareAndSwapInt32(&flags, 0, 1)

The pointer-based API operates on raw *int32, *int64, etc., rather than wrapper types. This is useful when atomic variables cannot use wrapper types (e.g., fields in kernel-shared structures).

128-bit Operations

128-bit atomics require 16-byte alignment. Use placement helpers for shared memory:

buf := make([]byte, 32)
_, ptr := atomix.PlaceAlignedUint128(buf, 0)
ptr.Store(lo, hi)

var v atomix.Uint128  // Type ensures alignment
v.Store(lo, hi)
Architecture 128-bit Implementation
amd64 LOCK CMPXCHG16B
arm64 LDXP/STXP (default) or CASP (-tags=lse2)
riscv64, loong64 Spinlock emulation (LL/SC on low 64 bits)

Note: 128-bit atomics are primarily useful for double-word CAS patterns (e.g., lock-free data structures with version counters).

Architecture Implementation

x86-64 (TSO)

x86-64 provides Total Store Ordering (TSO), a strong memory model where:

  • All loads have implicit acquire semantics
  • All stores have implicit release semantics
  • Store-load ordering requires explicit barrier (MFENCE) or locked instruction

Consequently, all ordering variants compile to identical machine code on x86-64. The primary benefit of explicit ordering on x86-64 is documentation and portability.

Operation Instruction Notes
Load MOV Plain memory access
Store MOV Plain memory access
Add LOCK XADD Returns old value
Swap XCHG Implicit LOCK
CAS LOCK CMPXCHG
And/Or/Xor LOCK CMPXCHG loop Returns old value via CAS loop
CAS128 LOCK CMPXCHG16B

Load and Store are implemented in pure Go for compiler inlining.

ARM64 (Weakly Ordered)

ARM64 has a weakly ordered memory model requiring explicit ordering instructions. LSE (Large System Extensions) provides atomic instructions with ordering suffixes:

Suffix meanings: No suffix = Relaxed, A = Acquire, L = Release, AL = Acquire-Release

Operation Relaxed Acquire Release AcqRel
Load LDR LDAR
Store STR STLR
Add LDADD LDADDA LDADDL LDADDAL
CAS CAS CASA CASL CASAL
Swap SWP SWPA SWPL SWPAL
And LDCLR LDCLRA LDCLRL LDCLRAL
Or LDSET LDSETA LDSETL LDSETAL
Xor LDEOR LDEORA LDEORL LDEORAL

LDCLR clears bits (AND with complement). To implement And(mask), pass ~mask.

Relaxed load/store are implemented in pure Go for inlining. Other orderings use assembly with LSE instructions.

128-bit Operations
Build Tag Instructions Target Hardware
(default) LDXP/STXP (LL/SC loop) All ARMv8+
-tags=lse2 CASP (single instruction) ARMv8.4+ with LSE2

LL/SC (Load-Link/Store-Conditional) retries on contention. CASP provides single-instruction atomicity but requires newer hardware.

RISC-V 64-bit

RISC-V RVWMO (Weak Memory Ordering) uses explicit fence instructions:

Operation Implementation
Load Relaxed LD
Load Acquire LD + FENCE R,RW
Store Relaxed SD
Store Release FENCE RW,W + SD
RMW AMO instructions with .aq/.rl modifiers

128-bit operations use spinlock-based emulation.

LoongArch 64-bit

LoongArch uses DBAR (data barrier) instructions:

Operation Implementation
Load Relaxed LD.D
Load Acquire LD.D + DBAR
Store Relaxed ST.D
Store Release DBAR + ST.D
RMW AM*_DB instructions

128-bit operations use spinlock-based emulation.

Fallback

Unsupported architectures use sync/atomic, which provides sequential consistency. 128-bit operations on fallback architectures are not atomic (two separate 64-bit operations).

Design Rationale

Why Explicit Memory Ordering?
  1. Performance on weak architectures: ARM64/RISC-V can use weaker (faster) instructions when full ordering isn't needed
  2. Documentation: Ordering suffix documents synchronization intent
  3. Portability: Code explicitly specifies requirements rather than relying on architecture-specific guarantees
  4. Correctness: Makes memory ordering decisions explicit and reviewable
Why Not Just Use sync/atomic?

sync/atomic provides sequential consistency, which is:

  • Sufficient for most use cases
  • Portable across all architectures
  • Simple to reason about

Use atomix when:

  • Building high-performance lock-free data structures
  • Interoperating with kernel or hardware interfaces (io_uring, shared memory)
  • Porting C/C++ code with explicit memory ordering
  • Targeting ARM64/RISC-V where weaker ordering provides measurable benefit

Platform Support

Platform Implementation
linux/amd64 Native assembly
linux/arm64 Native assembly with LSE
linux/riscv64 Native assembly (128-bit emulated)
linux/loong64 Native assembly (128-bit emulated)
darwin/amd64, darwin/arm64 Native assembly
freebsd/amd64, freebsd/arm64 Native assembly
Other sync/atomic fallback

Compiler Intrinsics

To bring out full performance, atomix can be integrated with the Go compiler to emit inline atomic instructions, eliminating function call overhead. See intrinsics.md for the implementation approach.

License

MIT — see LICENSE.

©2026 Hayabusa Cloud Co., Ltd.

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:

Cache-line padded variants prevent false sharing:

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:

Index

Constants

View Source
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

func CanPlaceAligned16(p []byte, off int) bool

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

func CanPlaceAligned4(p []byte, off int) bool

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

func CanPlaceAligned8(p []byte, off int) bool

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

func CanPlaceCacheAligned(p []byte, off, size int) bool

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

func NewAllocator(buf []byte) *Allocator

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) Align

func (a *Allocator) Align(alignment int)

Align advances the offset to the next multiple of alignment.

func (*Allocator) Bool

func (a *Allocator) Bool() *Bool

Bool allocates and returns a Bool at a 4-byte aligned address.

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) Int128

func (a *Allocator) Int128() *Int128

Int128 allocates and returns an Int128 at a 16-byte aligned address.

func (*Allocator) Int32

func (a *Allocator) Int32() *Int32

Int32 allocates and returns an Int32 at a 4-byte aligned address.

func (*Allocator) Int64

func (a *Allocator) Int64() *Int64

Int64 allocates and returns an Int64 at an 8-byte aligned address.

func (*Allocator) Offset

func (a *Allocator) Offset() int

Offset returns the current allocation offset.

func (*Allocator) Remaining

func (a *Allocator) Remaining() int

Remaining returns the number of bytes remaining in the buffer.

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.

func (*Allocator) Skip

func (a *Allocator) Skip(n int)

Skip advances the offset by n bytes.

func (*Allocator) Uint128

func (a *Allocator) Uint128() *Uint128

Uint128 allocates and returns a Uint128 at a 16-byte aligned address.

func (*Allocator) Uint32

func (a *Allocator) Uint32() *Uint32

Uint32 allocates and returns a Uint32 at a 4-byte aligned address.

func (*Allocator) Uint64

func (a *Allocator) Uint64() *Uint64

Uint64 allocates and returns a Uint64 at an 8-byte aligned address.

func (*Allocator) Uintptr

func (a *Allocator) Uintptr() *Uintptr

Uintptr allocates and returns a Uintptr at a pointer-aligned address.

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

func PlaceAlignedBool(p []byte, off int) (n int, a *Bool)

PlaceAlignedBool places a Bool at a 4-byte aligned address in p.

func (*Bool) CompareAndSwap

func (a *Bool) CompareAndSwap(old, new bool) bool

CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.

func (*Bool) CompareAndSwapAcqRel

func (a *Bool) CompareAndSwapAcqRel(old, new bool) bool

CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.

func (*Bool) CompareAndSwapAcquire

func (a *Bool) CompareAndSwapAcquire(old, new bool) bool

CompareAndSwapAcquire atomically compares and swaps with acquire ordering.

func (*Bool) CompareAndSwapRelaxed

func (a *Bool) CompareAndSwapRelaxed(old, new bool) bool

CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.

func (*Bool) CompareAndSwapRelease

func (a *Bool) CompareAndSwapRelease(old, new bool) bool

CompareAndSwapRelease atomically compares and swaps with release ordering.

func (*Bool) Load

func (a *Bool) Load() bool

Load atomically loads and returns the value with relaxed ordering.

func (*Bool) LoadAcquire

func (a *Bool) LoadAcquire() bool

LoadAcquire atomically loads and returns the value with acquire ordering.

func (*Bool) LoadRelaxed

func (a *Bool) LoadRelaxed() bool

LoadRelaxed atomically loads and returns the value with relaxed ordering.

func (*Bool) Store

func (a *Bool) Store(val bool)

Store atomically stores val with relaxed ordering.

func (*Bool) StoreRelaxed

func (a *Bool) StoreRelaxed(val bool)

StoreRelaxed atomically stores val with relaxed ordering.

func (*Bool) StoreRelease

func (a *Bool) StoreRelease(val bool)

StoreRelease atomically stores val with release ordering.

func (*Bool) Swap

func (a *Bool) Swap(new bool) bool

Swap atomically swaps the value and returns the old value with acquire-release ordering.

func (*Bool) SwapAcqRel

func (a *Bool) SwapAcqRel(new bool) bool

SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.

func (*Bool) SwapAcquire

func (a *Bool) SwapAcquire(new bool) bool

SwapAcquire atomically swaps the value and returns the old value with acquire ordering.

func (*Bool) SwapRelaxed

func (a *Bool) SwapRelaxed(new bool) bool

SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.

func (*Bool) SwapRelease

func (a *Bool) SwapRelease(new bool) bool

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

func PlaceAlignedInt128(p []byte, off int) (n int, a *Int128)

PlaceAlignedInt128 places an Int128 at a 16-byte aligned address in p.

func (*Int128) Add

func (a *Int128) Add(deltaLo, deltaHi int64) (lo, hi int64)

Add atomically adds (deltaLo, deltaHi) and returns the new value. Uses acquire-release ordering.

func (*Int128) AddRelaxed

func (a *Int128) AddRelaxed(deltaLo, deltaHi int64) (lo, hi int64)

AddRelaxed atomically adds (deltaLo, deltaHi) and returns the new value.

func (*Int128) CompareAndSwap

func (a *Int128) CompareAndSwap(oldLo, oldHi, newLo, newHi int64) bool

CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.

func (*Int128) CompareAndSwapAcqRel

func (a *Int128) CompareAndSwapAcqRel(oldLo, oldHi, newLo, newHi int64) bool

CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.

func (*Int128) CompareAndSwapAcquire

func (a *Int128) CompareAndSwapAcquire(oldLo, oldHi, newLo, newHi int64) bool

CompareAndSwapAcquire atomically compares and swaps with acquire ordering.

func (*Int128) CompareAndSwapRelaxed

func (a *Int128) CompareAndSwapRelaxed(oldLo, oldHi, newLo, newHi int64) bool

CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.

func (*Int128) CompareAndSwapRelease

func (a *Int128) CompareAndSwapRelease(oldLo, oldHi, newLo, newHi int64) bool

CompareAndSwapRelease atomically compares and swaps with release ordering.

func (*Int128) CompareExchange

func (a *Int128) CompareExchange(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)

CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.

func (*Int128) CompareExchangeAcqRel

func (a *Int128) CompareExchangeAcqRel(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)

CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.

func (*Int128) CompareExchangeAcquire

func (a *Int128) CompareExchangeAcquire(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)

CompareExchangeAcquire atomically compares and swaps with acquire ordering.

func (*Int128) CompareExchangeRelaxed

func (a *Int128) CompareExchangeRelaxed(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)

CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.

func (*Int128) CompareExchangeRelease

func (a *Int128) CompareExchangeRelease(oldLo, oldHi, newLo, newHi int64) (lo, hi int64)

CompareExchangeRelease atomically compares and swaps with release ordering.

func (*Int128) Dec

func (a *Int128) Dec() (lo, hi int64)

Dec atomically decrements by 1 and returns the new value. Uses acquire-release ordering.

func (*Int128) DecRelaxed

func (a *Int128) DecRelaxed() (lo, hi int64)

DecRelaxed atomically decrements by 1 and returns the new value.

func (*Int128) Equal

func (a *Int128) Equal(lo, hi int64) bool

Equal atomically loads and compares for equality. Uses acquire ordering.

func (*Int128) EqualRelaxed

func (a *Int128) EqualRelaxed(lo, hi int64) bool

EqualRelaxed atomically loads and compares with relaxed ordering.

func (*Int128) Greater

func (a *Int128) Greater(lo, hi int64) bool

Greater atomically loads and returns true if value > (lo, hi). Uses acquire ordering. Comparison is signed.

func (*Int128) GreaterOrEqual

func (a *Int128) GreaterOrEqual(lo, hi int64) bool

GreaterOrEqual atomically loads and returns true if value >= (lo, hi). Uses acquire ordering. Comparison is signed.

func (*Int128) GreaterOrEqualRelaxed

func (a *Int128) GreaterOrEqualRelaxed(lo, hi int64) bool

GreaterOrEqualRelaxed atomically loads and compares with relaxed ordering.

func (*Int128) GreaterRelaxed

func (a *Int128) GreaterRelaxed(lo, hi int64) bool

GreaterRelaxed atomically loads and compares with relaxed ordering.

func (*Int128) Inc

func (a *Int128) Inc() (lo, hi int64)

Inc atomically increments by 1 and returns the new value. Uses acquire-release ordering.

func (*Int128) IncRelaxed

func (a *Int128) IncRelaxed() (lo, hi int64)

IncRelaxed atomically increments by 1 and returns the new value.

func (*Int128) Less

func (a *Int128) Less(lo, hi int64) bool

Less atomically loads and returns true if value < (lo, hi). Uses acquire ordering. Comparison is signed.

func (*Int128) LessOrEqual

func (a *Int128) LessOrEqual(lo, hi int64) bool

LessOrEqual atomically loads and returns true if value <= (lo, hi). Uses acquire ordering. Comparison is signed.

func (*Int128) LessOrEqualRelaxed

func (a *Int128) LessOrEqualRelaxed(lo, hi int64) bool

LessOrEqualRelaxed atomically loads and compares with relaxed ordering.

func (*Int128) LessRelaxed

func (a *Int128) LessRelaxed(lo, hi int64) bool

LessRelaxed atomically loads and compares with relaxed ordering.

func (*Int128) Load

func (a *Int128) Load() (lo, hi int64)

Load atomically loads and returns the value with relaxed ordering. Returns (lo, hi) where the full value is (hi << 64) | lo.

func (*Int128) LoadAcquire

func (a *Int128) LoadAcquire() (lo, hi int64)

LoadAcquire atomically loads and returns the value with acquire ordering.

func (*Int128) LoadRelaxed

func (a *Int128) LoadRelaxed() (lo, hi int64)

LoadRelaxed atomically loads and returns the value with relaxed ordering.

func (*Int128) Store

func (a *Int128) Store(lo, hi int64)

Store atomically stores val with relaxed ordering.

func (*Int128) StoreRelaxed

func (a *Int128) StoreRelaxed(lo, hi int64)

StoreRelaxed atomically stores val with relaxed ordering.

func (*Int128) StoreRelease

func (a *Int128) StoreRelease(lo, hi int64)

StoreRelease atomically stores val with release ordering.

func (*Int128) Sub

func (a *Int128) Sub(deltaLo, deltaHi int64) (lo, hi int64)

Sub atomically subtracts (deltaLo, deltaHi) and returns the new value. Uses acquire-release ordering.

func (*Int128) SubRelaxed

func (a *Int128) SubRelaxed(deltaLo, deltaHi int64) (lo, hi int64)

SubRelaxed atomically subtracts (deltaLo, deltaHi) and returns the new value.

func (*Int128) Swap

func (a *Int128) Swap(newLo, newHi int64) (oldLo, oldHi int64)

Swap atomically stores new value and returns the old value. Uses acquire-release ordering.

func (*Int128) SwapAcqRel

func (a *Int128) SwapAcqRel(newLo, newHi int64) (oldLo, oldHi int64)

SwapAcqRel atomically stores new value and returns the old value with acquire-release ordering.

func (*Int128) SwapAcquire

func (a *Int128) SwapAcquire(newLo, newHi int64) (oldLo, oldHi int64)

SwapAcquire atomically stores new value and returns the old value with acquire ordering.

func (*Int128) SwapRelaxed

func (a *Int128) SwapRelaxed(newLo, newHi int64) (oldLo, oldHi int64)

SwapRelaxed atomically stores new value and returns the old value with relaxed ordering.

func (*Int128) SwapRelease

func (a *Int128) SwapRelease(newLo, newHi int64) (oldLo, oldHi int64)

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

func PlaceAlignedInt32(p []byte, off int) (n int, a *Int32)

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

func (a *Int32) Add(delta int32) int32

Add atomically adds delta and returns the new value with acquire-release ordering.

func (*Int32) AddAcqRel

func (a *Int32) AddAcqRel(delta int32) int32

AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.

func (*Int32) AddAcquire

func (a *Int32) AddAcquire(delta int32) int32

AddAcquire atomically adds delta and returns the new value with acquire ordering.

func (*Int32) AddRelaxed

func (a *Int32) AddRelaxed(delta int32) int32

AddRelaxed atomically adds delta and returns the new value with relaxed ordering.

func (*Int32) AddRelease

func (a *Int32) AddRelease(delta int32) int32

AddRelease atomically adds delta and returns the new value with release ordering.

func (*Int32) And

func (a *Int32) And(mask int32) int32

And atomically performs bitwise AND and returns the old value with acquire-release ordering.

func (*Int32) AndAcqRel

func (a *Int32) AndAcqRel(mask int32) int32

AndAcqRel atomically performs bitwise AND with acquire-release ordering.

func (*Int32) AndAcquire

func (a *Int32) AndAcquire(mask int32) int32

AndAcquire atomically performs bitwise AND with acquire ordering.

func (*Int32) AndRelaxed

func (a *Int32) AndRelaxed(mask int32) int32

AndRelaxed atomically performs bitwise AND with relaxed ordering.

func (*Int32) AndRelease

func (a *Int32) AndRelease(mask int32) int32

AndRelease atomically performs bitwise AND with release ordering.

func (*Int32) CompareAndSwap

func (a *Int32) CompareAndSwap(old, new int32) bool

CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.

func (*Int32) CompareAndSwapAcqRel

func (a *Int32) CompareAndSwapAcqRel(old, new int32) bool

CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.

func (*Int32) CompareAndSwapAcquire

func (a *Int32) CompareAndSwapAcquire(old, new int32) bool

CompareAndSwapAcquire atomically compares and swaps with acquire ordering.

func (*Int32) CompareAndSwapRelaxed

func (a *Int32) CompareAndSwapRelaxed(old, new int32) bool

CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.

func (*Int32) CompareAndSwapRelease

func (a *Int32) CompareAndSwapRelease(old, new int32) bool

CompareAndSwapRelease atomically compares and swaps with release ordering.

func (*Int32) CompareExchange

func (a *Int32) CompareExchange(old, new int32) int32

CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.

func (*Int32) CompareExchangeAcqRel

func (a *Int32) CompareExchangeAcqRel(old, new int32) int32

CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.

func (*Int32) CompareExchangeAcquire

func (a *Int32) CompareExchangeAcquire(old, new int32) int32

CompareExchangeAcquire atomically compares and swaps with acquire ordering.

func (*Int32) CompareExchangeRelaxed

func (a *Int32) CompareExchangeRelaxed(old, new int32) int32

CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.

func (*Int32) CompareExchangeRelease

func (a *Int32) CompareExchangeRelease(old, new int32) int32

CompareExchangeRelease atomically compares and swaps with release ordering.

func (*Int32) Load

func (a *Int32) Load() int32

Load atomically loads and returns the value with relaxed ordering.

func (*Int32) LoadAcquire

func (a *Int32) LoadAcquire() int32

LoadAcquire atomically loads and returns the value with acquire ordering.

func (*Int32) LoadRelaxed

func (a *Int32) LoadRelaxed() int32

LoadRelaxed atomically loads and returns the value with relaxed ordering.

func (*Int32) Max

func (a *Int32) Max(val int32) int32

Max atomically stores the maximum of current and val, returning the old value. Uses acquire-release ordering.

func (*Int32) MaxRelaxed

func (a *Int32) MaxRelaxed(val int32) int32

MaxRelaxed atomically stores the maximum with relaxed ordering.

func (*Int32) Min

func (a *Int32) Min(val int32) int32

Min atomically stores the minimum of current and val, returning the old value. Uses acquire-release ordering.

func (*Int32) MinRelaxed

func (a *Int32) MinRelaxed(val int32) int32

MinRelaxed atomically stores the minimum with relaxed ordering.

func (*Int32) Or

func (a *Int32) Or(mask int32) int32

Or atomically performs bitwise OR and returns the old value with acquire-release ordering.

func (*Int32) OrAcqRel

func (a *Int32) OrAcqRel(mask int32) int32

OrAcqRel atomically performs bitwise OR with acquire-release ordering.

func (*Int32) OrAcquire

func (a *Int32) OrAcquire(mask int32) int32

OrAcquire atomically performs bitwise OR with acquire ordering.

func (*Int32) OrRelaxed

func (a *Int32) OrRelaxed(mask int32) int32

OrRelaxed atomically performs bitwise OR with relaxed ordering.

func (*Int32) OrRelease

func (a *Int32) OrRelease(mask int32) int32

OrRelease atomically performs bitwise OR with release ordering.

func (*Int32) Store

func (a *Int32) Store(val int32)

Store atomically stores val with relaxed ordering.

func (*Int32) StoreRelaxed

func (a *Int32) StoreRelaxed(val int32)

StoreRelaxed atomically stores val with relaxed ordering.

func (*Int32) StoreRelease

func (a *Int32) StoreRelease(val int32)

StoreRelease atomically stores val with release ordering.

func (*Int32) Sub

func (a *Int32) Sub(delta int32) int32

Sub atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Int32) SubAcqRel

func (a *Int32) SubAcqRel(delta int32) int32

SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Int32) SubAcquire

func (a *Int32) SubAcquire(delta int32) int32

SubAcquire atomically subtracts delta and returns the new value with acquire ordering.

func (*Int32) SubRelaxed

func (a *Int32) SubRelaxed(delta int32) int32

SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.

func (*Int32) SubRelease

func (a *Int32) SubRelease(delta int32) int32

SubRelease atomically subtracts delta and returns the new value with release ordering.

func (*Int32) Swap

func (a *Int32) Swap(new int32) int32

Swap atomically swaps the value and returns the old value with acquire-release ordering.

func (*Int32) SwapAcqRel

func (a *Int32) SwapAcqRel(new int32) int32

SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.

func (*Int32) SwapAcquire

func (a *Int32) SwapAcquire(new int32) int32

SwapAcquire atomically swaps the value and returns the old value with acquire ordering.

func (*Int32) SwapRelaxed

func (a *Int32) SwapRelaxed(new int32) int32

SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.

func (*Int32) SwapRelease

func (a *Int32) SwapRelease(new int32) int32

SwapRelease atomically swaps the value and returns the old value with release ordering.

func (*Int32) Xor

func (a *Int32) Xor(mask int32) int32

Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.

func (*Int32) XorAcqRel

func (a *Int32) XorAcqRel(mask int32) int32

XorAcqRel atomically performs bitwise XOR with acquire-release ordering.

func (*Int32) XorAcquire

func (a *Int32) XorAcquire(mask int32) int32

XorAcquire atomically performs bitwise XOR with acquire ordering.

func (*Int32) XorRelaxed

func (a *Int32) XorRelaxed(mask int32) int32

XorRelaxed atomically performs bitwise XOR with relaxed ordering.

func (*Int32) XorRelease

func (a *Int32) XorRelease(mask int32) int32

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

func PlaceAlignedInt64(p []byte, off int) (n int, a *Int64)

PlaceAlignedInt64 places an Int64 at an 8-byte aligned address in p.

func (*Int64) Add

func (a *Int64) Add(delta int64) int64

Add atomically adds delta and returns the new value with acquire-release ordering.

func (*Int64) AddAcqRel

func (a *Int64) AddAcqRel(delta int64) int64

AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.

func (*Int64) AddAcquire

func (a *Int64) AddAcquire(delta int64) int64

AddAcquire atomically adds delta and returns the new value with acquire ordering.

func (*Int64) AddRelaxed

func (a *Int64) AddRelaxed(delta int64) int64

AddRelaxed atomically adds delta and returns the new value with relaxed ordering.

func (*Int64) AddRelease

func (a *Int64) AddRelease(delta int64) int64

AddRelease atomically adds delta and returns the new value with release ordering.

func (*Int64) And

func (a *Int64) And(mask int64) int64

And atomically performs bitwise AND and returns the old value with acquire-release ordering.

func (*Int64) AndAcqRel

func (a *Int64) AndAcqRel(mask int64) int64

AndAcqRel atomically performs bitwise AND with acquire-release ordering.

func (*Int64) AndAcquire

func (a *Int64) AndAcquire(mask int64) int64

AndAcquire atomically performs bitwise AND with acquire ordering.

func (*Int64) AndRelaxed

func (a *Int64) AndRelaxed(mask int64) int64

AndRelaxed atomically performs bitwise AND with relaxed ordering.

func (*Int64) AndRelease

func (a *Int64) AndRelease(mask int64) int64

AndRelease atomically performs bitwise AND with release ordering.

func (*Int64) CompareAndSwap

func (a *Int64) CompareAndSwap(old, new int64) bool

CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.

func (*Int64) CompareAndSwapAcqRel

func (a *Int64) CompareAndSwapAcqRel(old, new int64) bool

CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.

func (*Int64) CompareAndSwapAcquire

func (a *Int64) CompareAndSwapAcquire(old, new int64) bool

CompareAndSwapAcquire atomically compares and swaps with acquire ordering.

func (*Int64) CompareAndSwapRelaxed

func (a *Int64) CompareAndSwapRelaxed(old, new int64) bool

CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.

func (*Int64) CompareAndSwapRelease

func (a *Int64) CompareAndSwapRelease(old, new int64) bool

CompareAndSwapRelease atomically compares and swaps with release ordering.

func (*Int64) CompareExchange

func (a *Int64) CompareExchange(old, new int64) int64

CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.

func (*Int64) CompareExchangeAcqRel

func (a *Int64) CompareExchangeAcqRel(old, new int64) int64

CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.

func (*Int64) CompareExchangeAcquire

func (a *Int64) CompareExchangeAcquire(old, new int64) int64

CompareExchangeAcquire atomically compares and swaps with acquire ordering.

func (*Int64) CompareExchangeRelaxed

func (a *Int64) CompareExchangeRelaxed(old, new int64) int64

CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.

func (*Int64) CompareExchangeRelease

func (a *Int64) CompareExchangeRelease(old, new int64) int64

CompareExchangeRelease atomically compares and swaps with release ordering.

func (*Int64) Load

func (a *Int64) Load() int64

Load atomically loads and returns the value with relaxed ordering.

func (*Int64) LoadAcquire

func (a *Int64) LoadAcquire() int64

LoadAcquire atomically loads and returns the value with acquire ordering.

func (*Int64) LoadRelaxed

func (a *Int64) LoadRelaxed() int64

LoadRelaxed atomically loads and returns the value with relaxed ordering.

func (*Int64) Max

func (a *Int64) Max(val int64) int64

Max atomically stores the maximum of current and val, returning the old value. Uses acquire-release ordering.

func (*Int64) MaxRelaxed

func (a *Int64) MaxRelaxed(val int64) int64

MaxRelaxed atomically stores the maximum with relaxed ordering.

func (*Int64) Min

func (a *Int64) Min(val int64) int64

Min atomically stores the minimum of current and val, returning the old value. Uses acquire-release ordering.

func (*Int64) MinRelaxed

func (a *Int64) MinRelaxed(val int64) int64

MinRelaxed atomically stores the minimum with relaxed ordering.

func (*Int64) Or

func (a *Int64) Or(mask int64) int64

Or atomically performs bitwise OR and returns the old value with acquire-release ordering.

func (*Int64) OrAcqRel

func (a *Int64) OrAcqRel(mask int64) int64

OrAcqRel atomically performs bitwise OR with acquire-release ordering.

func (*Int64) OrAcquire

func (a *Int64) OrAcquire(mask int64) int64

OrAcquire atomically performs bitwise OR with acquire ordering.

func (*Int64) OrRelaxed

func (a *Int64) OrRelaxed(mask int64) int64

OrRelaxed atomically performs bitwise OR with relaxed ordering.

func (*Int64) OrRelease

func (a *Int64) OrRelease(mask int64) int64

OrRelease atomically performs bitwise OR with release ordering.

func (*Int64) Store

func (a *Int64) Store(val int64)

Store atomically stores val with relaxed ordering.

func (*Int64) StoreRelaxed

func (a *Int64) StoreRelaxed(val int64)

StoreRelaxed atomically stores val with relaxed ordering.

func (*Int64) StoreRelease

func (a *Int64) StoreRelease(val int64)

StoreRelease atomically stores val with release ordering.

func (*Int64) Sub

func (a *Int64) Sub(delta int64) int64

Sub atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Int64) SubAcqRel

func (a *Int64) SubAcqRel(delta int64) int64

SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Int64) SubAcquire

func (a *Int64) SubAcquire(delta int64) int64

SubAcquire atomically subtracts delta and returns the new value with acquire ordering.

func (*Int64) SubRelaxed

func (a *Int64) SubRelaxed(delta int64) int64

SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.

func (*Int64) SubRelease

func (a *Int64) SubRelease(delta int64) int64

SubRelease atomically subtracts delta and returns the new value with release ordering.

func (*Int64) Swap

func (a *Int64) Swap(new int64) int64

Swap atomically swaps the value and returns the old value with acquire-release ordering.

func (*Int64) SwapAcqRel

func (a *Int64) SwapAcqRel(new int64) int64

SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.

func (*Int64) SwapAcquire

func (a *Int64) SwapAcquire(new int64) int64

SwapAcquire atomically swaps the value and returns the old value with acquire ordering.

func (*Int64) SwapRelaxed

func (a *Int64) SwapRelaxed(new int64) int64

SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.

func (*Int64) SwapRelease

func (a *Int64) SwapRelease(new int64) int64

SwapRelease atomically swaps the value and returns the old value with release ordering.

func (*Int64) Xor

func (a *Int64) Xor(mask int64) int64

Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.

func (*Int64) XorAcqRel

func (a *Int64) XorAcqRel(mask int64) int64

XorAcqRel atomically performs bitwise XOR with acquire-release ordering.

func (*Int64) XorAcquire

func (a *Int64) XorAcquire(mask int64) int64

XorAcquire atomically performs bitwise XOR with acquire ordering.

func (*Int64) XorRelaxed

func (a *Int64) XorRelaxed(mask int64) int64

XorRelaxed atomically performs bitwise XOR with relaxed ordering.

func (*Int64) XorRelease

func (a *Int64) XorRelease(mask int64) int64

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

func (o MemoryOrder) SwapPointer(addr *unsafe.Pointer, new unsafe.Pointer) (old unsafe.Pointer)

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

func (a *Pointer[T]) CompareAndSwap(old, new *T) bool

CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.

func (*Pointer[T]) CompareAndSwapAcqRel

func (a *Pointer[T]) CompareAndSwapAcqRel(old, new *T) bool

CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.

func (*Pointer[T]) CompareAndSwapAcquire

func (a *Pointer[T]) CompareAndSwapAcquire(old, new *T) bool

CompareAndSwapAcquire atomically compares and swaps with acquire ordering.

func (*Pointer[T]) CompareAndSwapRelaxed

func (a *Pointer[T]) CompareAndSwapRelaxed(old, new *T) bool

CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.

func (*Pointer[T]) CompareAndSwapRelease

func (a *Pointer[T]) CompareAndSwapRelease(old, new *T) bool

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

func PlaceAlignedUint128(p []byte, off int) (n int, a *Uint128)

PlaceAlignedUint128 places a Uint128 at a 16-byte aligned address in p.

func (*Uint128) Add

func (a *Uint128) Add(deltaLo, deltaHi uint64) (newLo, newHi uint64)

Add atomically adds (deltaLo, deltaHi) and returns the new value. Uses acquire-release ordering.

func (*Uint128) AddRelaxed

func (a *Uint128) AddRelaxed(deltaLo, deltaHi uint64) (newLo, newHi uint64)

AddRelaxed atomically adds (deltaLo, deltaHi) and returns the new value.

func (*Uint128) CompareAndSwap

func (a *Uint128) CompareAndSwap(oldLo, oldHi, newLo, newHi uint64) bool

CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.

func (*Uint128) CompareAndSwapAcqRel

func (a *Uint128) CompareAndSwapAcqRel(oldLo, oldHi, newLo, newHi uint64) bool

CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.

func (*Uint128) CompareAndSwapAcquire

func (a *Uint128) CompareAndSwapAcquire(oldLo, oldHi, newLo, newHi uint64) bool

CompareAndSwapAcquire atomically compares and swaps with acquire ordering.

func (*Uint128) CompareAndSwapRelaxed

func (a *Uint128) CompareAndSwapRelaxed(oldLo, oldHi, newLo, newHi uint64) bool

CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.

func (*Uint128) CompareAndSwapRelease

func (a *Uint128) CompareAndSwapRelease(oldLo, oldHi, newLo, newHi uint64) bool

CompareAndSwapRelease atomically compares and swaps with release ordering.

func (*Uint128) CompareExchange

func (a *Uint128) CompareExchange(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)

CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.

func (*Uint128) CompareExchangeAcqRel

func (a *Uint128) CompareExchangeAcqRel(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)

CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.

func (*Uint128) CompareExchangeAcquire

func (a *Uint128) CompareExchangeAcquire(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)

CompareExchangeAcquire atomically compares and swaps with acquire ordering.

func (*Uint128) CompareExchangeRelaxed

func (a *Uint128) CompareExchangeRelaxed(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)

CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.

func (*Uint128) CompareExchangeRelease

func (a *Uint128) CompareExchangeRelease(oldLo, oldHi, newLo, newHi uint64) (lo, hi uint64)

CompareExchangeRelease atomically compares and swaps with release ordering.

func (*Uint128) Dec

func (a *Uint128) Dec() (newLo, newHi uint64)

Dec atomically decrements by 1 and returns the new value. Uses acquire-release ordering.

func (*Uint128) DecRelaxed

func (a *Uint128) DecRelaxed() (newLo, newHi uint64)

DecRelaxed atomically decrements by 1 and returns the new value.

func (*Uint128) Equal

func (a *Uint128) Equal(lo, hi uint64) bool

Equal atomically loads and compares for equality. Uses acquire ordering.

func (*Uint128) EqualRelaxed

func (a *Uint128) EqualRelaxed(lo, hi uint64) bool

EqualRelaxed atomically loads and compares with relaxed ordering.

func (*Uint128) Greater

func (a *Uint128) Greater(lo, hi uint64) bool

Greater atomically loads and returns true if value > (lo, hi). Uses acquire ordering.

func (*Uint128) GreaterOrEqual

func (a *Uint128) GreaterOrEqual(lo, hi uint64) bool

GreaterOrEqual atomically loads and returns true if value >= (lo, hi). Uses acquire ordering.

func (*Uint128) GreaterOrEqualRelaxed

func (a *Uint128) GreaterOrEqualRelaxed(lo, hi uint64) bool

GreaterOrEqualRelaxed atomically loads and compares with relaxed ordering.

func (*Uint128) GreaterRelaxed

func (a *Uint128) GreaterRelaxed(lo, hi uint64) bool

GreaterRelaxed atomically loads and compares with relaxed ordering.

func (*Uint128) Inc

func (a *Uint128) Inc() (newLo, newHi uint64)

Inc atomically increments by 1 and returns the new value. Uses acquire-release ordering.

func (*Uint128) IncRelaxed

func (a *Uint128) IncRelaxed() (newLo, newHi uint64)

IncRelaxed atomically increments by 1 and returns the new value.

func (*Uint128) Less

func (a *Uint128) Less(lo, hi uint64) bool

Less atomically loads and returns true if value < (lo, hi). Uses acquire ordering.

func (*Uint128) LessOrEqual

func (a *Uint128) LessOrEqual(lo, hi uint64) bool

LessOrEqual atomically loads and returns true if value <= (lo, hi). Uses acquire ordering.

func (*Uint128) LessOrEqualRelaxed

func (a *Uint128) LessOrEqualRelaxed(lo, hi uint64) bool

LessOrEqualRelaxed atomically loads and compares with relaxed ordering.

func (*Uint128) LessRelaxed

func (a *Uint128) LessRelaxed(lo, hi uint64) bool

LessRelaxed atomically loads and compares with relaxed ordering.

func (*Uint128) Load

func (a *Uint128) Load() (lo, hi uint64)

Load atomically loads and returns the value with relaxed ordering.

func (*Uint128) LoadAcquire

func (a *Uint128) LoadAcquire() (lo, hi uint64)

LoadAcquire atomically loads and returns the value with acquire ordering.

func (*Uint128) LoadRelaxed

func (a *Uint128) LoadRelaxed() (lo, hi uint64)

LoadRelaxed atomically loads and returns the value with relaxed ordering.

func (*Uint128) Store

func (a *Uint128) Store(lo, hi uint64)

Store atomically stores val with relaxed ordering.

func (*Uint128) StoreRelaxed

func (a *Uint128) StoreRelaxed(lo, hi uint64)

StoreRelaxed atomically stores val with relaxed ordering.

func (*Uint128) StoreRelease

func (a *Uint128) StoreRelease(lo, hi uint64)

StoreRelease atomically stores val with release ordering.

func (*Uint128) Sub

func (a *Uint128) Sub(deltaLo, deltaHi uint64) (newLo, newHi uint64)

Sub atomically subtracts (deltaLo, deltaHi) and returns the new value. Uses acquire-release ordering.

func (*Uint128) SubRelaxed

func (a *Uint128) SubRelaxed(deltaLo, deltaHi uint64) (newLo, newHi uint64)

SubRelaxed atomically subtracts (deltaLo, deltaHi) and returns the new value.

func (*Uint128) Swap

func (a *Uint128) Swap(newLo, newHi uint64) (oldLo, oldHi uint64)

Swap atomically stores new value and returns the old value. Uses acquire-release ordering.

func (*Uint128) SwapAcqRel

func (a *Uint128) SwapAcqRel(newLo, newHi uint64) (oldLo, oldHi uint64)

SwapAcqRel atomically stores new value and returns the old value with acquire-release ordering.

func (*Uint128) SwapAcquire

func (a *Uint128) SwapAcquire(newLo, newHi uint64) (oldLo, oldHi uint64)

SwapAcquire atomically stores new value and returns the old value with acquire ordering.

func (*Uint128) SwapRelaxed

func (a *Uint128) SwapRelaxed(newLo, newHi uint64) (oldLo, oldHi uint64)

SwapRelaxed atomically stores new value and returns the old value with relaxed ordering.

func (*Uint128) SwapRelease

func (a *Uint128) SwapRelease(newLo, newHi uint64) (oldLo, oldHi uint64)

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

func PlaceAlignedUint32(p []byte, off int) (n int, a *Uint32)

PlaceAlignedUint32 places a Uint32 at a 4-byte aligned address in p.

func (*Uint32) Add

func (a *Uint32) Add(delta uint32) uint32

Add atomically adds delta and returns the new value with acquire-release ordering.

func (*Uint32) AddAcqRel

func (a *Uint32) AddAcqRel(delta uint32) uint32

AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.

func (*Uint32) AddAcquire

func (a *Uint32) AddAcquire(delta uint32) uint32

AddAcquire atomically adds delta and returns the new value with acquire ordering.

func (*Uint32) AddRelaxed

func (a *Uint32) AddRelaxed(delta uint32) uint32

AddRelaxed atomically adds delta and returns the new value with relaxed ordering.

func (*Uint32) AddRelease

func (a *Uint32) AddRelease(delta uint32) uint32

AddRelease atomically adds delta and returns the new value with release ordering.

func (*Uint32) And

func (a *Uint32) And(mask uint32) uint32

And atomically performs bitwise AND and returns the old value with acquire-release ordering.

func (*Uint32) AndAcqRel

func (a *Uint32) AndAcqRel(mask uint32) uint32

AndAcqRel atomically performs bitwise AND with acquire-release ordering.

func (*Uint32) AndAcquire

func (a *Uint32) AndAcquire(mask uint32) uint32

AndAcquire atomically performs bitwise AND with acquire ordering.

func (*Uint32) AndRelaxed

func (a *Uint32) AndRelaxed(mask uint32) uint32

AndRelaxed atomically performs bitwise AND with relaxed ordering.

func (*Uint32) AndRelease

func (a *Uint32) AndRelease(mask uint32) uint32

AndRelease atomically performs bitwise AND with release ordering.

func (*Uint32) CompareAndSwap

func (a *Uint32) CompareAndSwap(old, new uint32) bool

CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.

func (*Uint32) CompareAndSwapAcqRel

func (a *Uint32) CompareAndSwapAcqRel(old, new uint32) bool

CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.

func (*Uint32) CompareAndSwapAcquire

func (a *Uint32) CompareAndSwapAcquire(old, new uint32) bool

CompareAndSwapAcquire atomically compares and swaps with acquire ordering.

func (*Uint32) CompareAndSwapRelaxed

func (a *Uint32) CompareAndSwapRelaxed(old, new uint32) bool

CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.

func (*Uint32) CompareAndSwapRelease

func (a *Uint32) CompareAndSwapRelease(old, new uint32) bool

CompareAndSwapRelease atomically compares and swaps with release ordering.

func (*Uint32) CompareExchange

func (a *Uint32) CompareExchange(old, new uint32) uint32

CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.

func (*Uint32) CompareExchangeAcqRel

func (a *Uint32) CompareExchangeAcqRel(old, new uint32) uint32

CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.

func (*Uint32) CompareExchangeAcquire

func (a *Uint32) CompareExchangeAcquire(old, new uint32) uint32

CompareExchangeAcquire atomically compares and swaps with acquire ordering.

func (*Uint32) CompareExchangeRelaxed

func (a *Uint32) CompareExchangeRelaxed(old, new uint32) uint32

CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.

func (*Uint32) CompareExchangeRelease

func (a *Uint32) CompareExchangeRelease(old, new uint32) uint32

CompareExchangeRelease atomically compares and swaps with release ordering.

func (*Uint32) Load

func (a *Uint32) Load() uint32

Load atomically loads and returns the value with relaxed ordering.

func (*Uint32) LoadAcquire

func (a *Uint32) LoadAcquire() uint32

LoadAcquire atomically loads and returns the value with acquire ordering.

func (*Uint32) LoadRelaxed

func (a *Uint32) LoadRelaxed() uint32

LoadRelaxed atomically loads and returns the value with relaxed ordering.

func (*Uint32) Max

func (a *Uint32) Max(val uint32) uint32

Max atomically stores the maximum of current and val, returning the old value. Uses acquire-release ordering.

func (*Uint32) MaxRelaxed

func (a *Uint32) MaxRelaxed(val uint32) uint32

MaxRelaxed atomically stores the maximum with relaxed ordering.

func (*Uint32) Min

func (a *Uint32) Min(val uint32) uint32

Min atomically stores the minimum of current and val, returning the old value. Uses acquire-release ordering.

func (*Uint32) MinRelaxed

func (a *Uint32) MinRelaxed(val uint32) uint32

MinRelaxed atomically stores the minimum with relaxed ordering.

func (*Uint32) Or

func (a *Uint32) Or(mask uint32) uint32

Or atomically performs bitwise OR and returns the old value with acquire-release ordering.

func (*Uint32) OrAcqRel

func (a *Uint32) OrAcqRel(mask uint32) uint32

OrAcqRel atomically performs bitwise OR with acquire-release ordering.

func (*Uint32) OrAcquire

func (a *Uint32) OrAcquire(mask uint32) uint32

OrAcquire atomically performs bitwise OR with acquire ordering.

func (*Uint32) OrRelaxed

func (a *Uint32) OrRelaxed(mask uint32) uint32

OrRelaxed atomically performs bitwise OR with relaxed ordering.

func (*Uint32) OrRelease

func (a *Uint32) OrRelease(mask uint32) uint32

OrRelease atomically performs bitwise OR with release ordering.

func (*Uint32) Store

func (a *Uint32) Store(val uint32)

Store atomically stores val with relaxed ordering.

func (*Uint32) StoreRelaxed

func (a *Uint32) StoreRelaxed(val uint32)

StoreRelaxed atomically stores val with relaxed ordering.

func (*Uint32) StoreRelease

func (a *Uint32) StoreRelease(val uint32)

StoreRelease atomically stores val with release ordering.

func (*Uint32) Sub

func (a *Uint32) Sub(delta uint32) uint32

Sub atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Uint32) SubAcqRel

func (a *Uint32) SubAcqRel(delta uint32) uint32

SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Uint32) SubAcquire

func (a *Uint32) SubAcquire(delta uint32) uint32

SubAcquire atomically subtracts delta and returns the new value with acquire ordering.

func (*Uint32) SubRelaxed

func (a *Uint32) SubRelaxed(delta uint32) uint32

SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.

func (*Uint32) SubRelease

func (a *Uint32) SubRelease(delta uint32) uint32

SubRelease atomically subtracts delta and returns the new value with release ordering.

func (*Uint32) Swap

func (a *Uint32) Swap(new uint32) uint32

Swap atomically swaps the value and returns the old value with acquire-release ordering.

func (*Uint32) SwapAcqRel

func (a *Uint32) SwapAcqRel(new uint32) uint32

SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.

func (*Uint32) SwapAcquire

func (a *Uint32) SwapAcquire(new uint32) uint32

SwapAcquire atomically swaps the value and returns the old value with acquire ordering.

func (*Uint32) SwapRelaxed

func (a *Uint32) SwapRelaxed(new uint32) uint32

SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.

func (*Uint32) SwapRelease

func (a *Uint32) SwapRelease(new uint32) uint32

SwapRelease atomically swaps the value and returns the old value with release ordering.

func (*Uint32) Xor

func (a *Uint32) Xor(mask uint32) uint32

Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.

func (*Uint32) XorAcqRel

func (a *Uint32) XorAcqRel(mask uint32) uint32

XorAcqRel atomically performs bitwise XOR with acquire-release ordering.

func (*Uint32) XorAcquire

func (a *Uint32) XorAcquire(mask uint32) uint32

XorAcquire atomically performs bitwise XOR with acquire ordering.

func (*Uint32) XorRelaxed

func (a *Uint32) XorRelaxed(mask uint32) uint32

XorRelaxed atomically performs bitwise XOR with relaxed ordering.

func (*Uint32) XorRelease

func (a *Uint32) XorRelease(mask uint32) uint32

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

func PlaceAlignedUint64(p []byte, off int) (n int, a *Uint64)

PlaceAlignedUint64 places a Uint64 at an 8-byte aligned address in p.

func (*Uint64) Add

func (a *Uint64) Add(delta uint64) uint64

Add atomically adds delta and returns the new value with acquire-release ordering.

func (*Uint64) AddAcqRel

func (a *Uint64) AddAcqRel(delta uint64) uint64

AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.

func (*Uint64) AddAcquire

func (a *Uint64) AddAcquire(delta uint64) uint64

AddAcquire atomically adds delta and returns the new value with acquire ordering.

func (*Uint64) AddRelaxed

func (a *Uint64) AddRelaxed(delta uint64) uint64

AddRelaxed atomically adds delta and returns the new value with relaxed ordering.

func (*Uint64) AddRelease

func (a *Uint64) AddRelease(delta uint64) uint64

AddRelease atomically adds delta and returns the new value with release ordering.

func (*Uint64) And

func (a *Uint64) And(mask uint64) uint64

And atomically performs bitwise AND and returns the old value with acquire-release ordering.

func (*Uint64) AndAcqRel

func (a *Uint64) AndAcqRel(mask uint64) uint64

AndAcqRel atomically performs bitwise AND with acquire-release ordering.

func (*Uint64) AndAcquire

func (a *Uint64) AndAcquire(mask uint64) uint64

AndAcquire atomically performs bitwise AND with acquire ordering.

func (*Uint64) AndRelaxed

func (a *Uint64) AndRelaxed(mask uint64) uint64

AndRelaxed atomically performs bitwise AND with relaxed ordering.

func (*Uint64) AndRelease

func (a *Uint64) AndRelease(mask uint64) uint64

AndRelease atomically performs bitwise AND with release ordering.

func (*Uint64) CompareAndSwap

func (a *Uint64) CompareAndSwap(old, new uint64) bool

CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.

func (*Uint64) CompareAndSwapAcqRel

func (a *Uint64) CompareAndSwapAcqRel(old, new uint64) bool

CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.

func (*Uint64) CompareAndSwapAcquire

func (a *Uint64) CompareAndSwapAcquire(old, new uint64) bool

CompareAndSwapAcquire atomically compares and swaps with acquire ordering.

func (*Uint64) CompareAndSwapRelaxed

func (a *Uint64) CompareAndSwapRelaxed(old, new uint64) bool

CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.

func (*Uint64) CompareAndSwapRelease

func (a *Uint64) CompareAndSwapRelease(old, new uint64) bool

CompareAndSwapRelease atomically compares and swaps with release ordering.

func (*Uint64) CompareExchange

func (a *Uint64) CompareExchange(old, new uint64) uint64

CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.

func (*Uint64) CompareExchangeAcqRel

func (a *Uint64) CompareExchangeAcqRel(old, new uint64) uint64

CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.

func (*Uint64) CompareExchangeAcquire

func (a *Uint64) CompareExchangeAcquire(old, new uint64) uint64

CompareExchangeAcquire atomically compares and swaps with acquire ordering.

func (*Uint64) CompareExchangeRelaxed

func (a *Uint64) CompareExchangeRelaxed(old, new uint64) uint64

CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.

func (*Uint64) CompareExchangeRelease

func (a *Uint64) CompareExchangeRelease(old, new uint64) uint64

CompareExchangeRelease atomically compares and swaps with release ordering.

func (*Uint64) Load

func (a *Uint64) Load() uint64

Load atomically loads and returns the value with relaxed ordering.

func (*Uint64) LoadAcquire

func (a *Uint64) LoadAcquire() uint64

LoadAcquire atomically loads and returns the value with acquire ordering.

func (*Uint64) LoadRelaxed

func (a *Uint64) LoadRelaxed() uint64

LoadRelaxed atomically loads and returns the value with relaxed ordering.

func (*Uint64) Max

func (a *Uint64) Max(val uint64) uint64

Max atomically stores the maximum of current and val, returning the old value. Uses acquire-release ordering.

func (*Uint64) MaxRelaxed

func (a *Uint64) MaxRelaxed(val uint64) uint64

MaxRelaxed atomically stores the maximum with relaxed ordering.

func (*Uint64) Min

func (a *Uint64) Min(val uint64) uint64

Min atomically stores the minimum of current and val, returning the old value. Uses acquire-release ordering.

func (*Uint64) MinRelaxed

func (a *Uint64) MinRelaxed(val uint64) uint64

MinRelaxed atomically stores the minimum with relaxed ordering.

func (*Uint64) Or

func (a *Uint64) Or(mask uint64) uint64

Or atomically performs bitwise OR and returns the old value with acquire-release ordering.

func (*Uint64) OrAcqRel

func (a *Uint64) OrAcqRel(mask uint64) uint64

OrAcqRel atomically performs bitwise OR with acquire-release ordering.

func (*Uint64) OrAcquire

func (a *Uint64) OrAcquire(mask uint64) uint64

OrAcquire atomically performs bitwise OR with acquire ordering.

func (*Uint64) OrRelaxed

func (a *Uint64) OrRelaxed(mask uint64) uint64

OrRelaxed atomically performs bitwise OR with relaxed ordering.

func (*Uint64) OrRelease

func (a *Uint64) OrRelease(mask uint64) uint64

OrRelease atomically performs bitwise OR with release ordering.

func (*Uint64) Store

func (a *Uint64) Store(val uint64)

Store atomically stores val with relaxed ordering.

func (*Uint64) StoreRelaxed

func (a *Uint64) StoreRelaxed(val uint64)

StoreRelaxed atomically stores val with relaxed ordering.

func (*Uint64) StoreRelease

func (a *Uint64) StoreRelease(val uint64)

StoreRelease atomically stores val with release ordering.

func (*Uint64) Sub

func (a *Uint64) Sub(delta uint64) uint64

Sub atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Uint64) SubAcqRel

func (a *Uint64) SubAcqRel(delta uint64) uint64

SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Uint64) SubAcquire

func (a *Uint64) SubAcquire(delta uint64) uint64

SubAcquire atomically subtracts delta and returns the new value with acquire ordering.

func (*Uint64) SubRelaxed

func (a *Uint64) SubRelaxed(delta uint64) uint64

SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.

func (*Uint64) SubRelease

func (a *Uint64) SubRelease(delta uint64) uint64

SubRelease atomically subtracts delta and returns the new value with release ordering.

func (*Uint64) Swap

func (a *Uint64) Swap(new uint64) uint64

Swap atomically swaps the value and returns the old value with acquire-release ordering.

func (*Uint64) SwapAcqRel

func (a *Uint64) SwapAcqRel(new uint64) uint64

SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.

func (*Uint64) SwapAcquire

func (a *Uint64) SwapAcquire(new uint64) uint64

SwapAcquire atomically swaps the value and returns the old value with acquire ordering.

func (*Uint64) SwapRelaxed

func (a *Uint64) SwapRelaxed(new uint64) uint64

SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.

func (*Uint64) SwapRelease

func (a *Uint64) SwapRelease(new uint64) uint64

SwapRelease atomically swaps the value and returns the old value with release ordering.

func (*Uint64) Xor

func (a *Uint64) Xor(mask uint64) uint64

Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.

func (*Uint64) XorAcqRel

func (a *Uint64) XorAcqRel(mask uint64) uint64

XorAcqRel atomically performs bitwise XOR with acquire-release ordering.

func (*Uint64) XorAcquire

func (a *Uint64) XorAcquire(mask uint64) uint64

XorAcquire atomically performs bitwise XOR with acquire ordering.

func (*Uint64) XorRelaxed

func (a *Uint64) XorRelaxed(mask uint64) uint64

XorRelaxed atomically performs bitwise XOR with relaxed ordering.

func (*Uint64) XorRelease

func (a *Uint64) XorRelease(mask uint64) uint64

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

func PlaceAlignedUintptr(p []byte, off int) (n int, a *Uintptr)

PlaceAlignedUintptr places a Uintptr at a pointer-aligned address in p.

func (*Uintptr) Add

func (a *Uintptr) Add(delta uintptr) uintptr

Add atomically adds delta and returns the new value with acquire-release ordering.

func (*Uintptr) AddAcqRel

func (a *Uintptr) AddAcqRel(delta uintptr) uintptr

AddAcqRel atomically adds delta and returns the new value with acquire-release ordering.

func (*Uintptr) AddAcquire

func (a *Uintptr) AddAcquire(delta uintptr) uintptr

AddAcquire atomically adds delta and returns the new value with acquire ordering.

func (*Uintptr) AddRelaxed

func (a *Uintptr) AddRelaxed(delta uintptr) uintptr

AddRelaxed atomically adds delta and returns the new value with relaxed ordering.

func (*Uintptr) AddRelease

func (a *Uintptr) AddRelease(delta uintptr) uintptr

AddRelease atomically adds delta and returns the new value with release ordering.

func (*Uintptr) And

func (a *Uintptr) And(mask uintptr) uintptr

And atomically performs bitwise AND and returns the old value with acquire-release ordering.

func (*Uintptr) AndAcqRel

func (a *Uintptr) AndAcqRel(mask uintptr) uintptr

AndAcqRel atomically performs bitwise AND with acquire-release ordering.

func (*Uintptr) AndAcquire

func (a *Uintptr) AndAcquire(mask uintptr) uintptr

AndAcquire atomically performs bitwise AND with acquire ordering.

func (*Uintptr) AndRelaxed

func (a *Uintptr) AndRelaxed(mask uintptr) uintptr

AndRelaxed atomically performs bitwise AND with relaxed ordering.

func (*Uintptr) AndRelease

func (a *Uintptr) AndRelease(mask uintptr) uintptr

AndRelease atomically performs bitwise AND with release ordering.

func (*Uintptr) CompareAndSwap

func (a *Uintptr) CompareAndSwap(old, new uintptr) bool

CompareAndSwap atomically compares and swaps with acquire-release ordering. Returns true if the swap was performed.

func (*Uintptr) CompareAndSwapAcqRel

func (a *Uintptr) CompareAndSwapAcqRel(old, new uintptr) bool

CompareAndSwapAcqRel atomically compares and swaps with acquire-release ordering.

func (*Uintptr) CompareAndSwapAcquire

func (a *Uintptr) CompareAndSwapAcquire(old, new uintptr) bool

CompareAndSwapAcquire atomically compares and swaps with acquire ordering.

func (*Uintptr) CompareAndSwapRelaxed

func (a *Uintptr) CompareAndSwapRelaxed(old, new uintptr) bool

CompareAndSwapRelaxed atomically compares and swaps with relaxed ordering.

func (*Uintptr) CompareAndSwapRelease

func (a *Uintptr) CompareAndSwapRelease(old, new uintptr) bool

CompareAndSwapRelease atomically compares and swaps with release ordering.

func (*Uintptr) CompareExchange

func (a *Uintptr) CompareExchange(old, new uintptr) uintptr

CompareExchange atomically compares and swaps, returning the old value. Uses acquire-release ordering.

func (*Uintptr) CompareExchangeAcqRel

func (a *Uintptr) CompareExchangeAcqRel(old, new uintptr) uintptr

CompareExchangeAcqRel atomically compares and swaps with acquire-release ordering.

func (*Uintptr) CompareExchangeAcquire

func (a *Uintptr) CompareExchangeAcquire(old, new uintptr) uintptr

CompareExchangeAcquire atomically compares and swaps with acquire ordering.

func (*Uintptr) CompareExchangeRelaxed

func (a *Uintptr) CompareExchangeRelaxed(old, new uintptr) uintptr

CompareExchangeRelaxed atomically compares and swaps with relaxed ordering.

func (*Uintptr) CompareExchangeRelease

func (a *Uintptr) CompareExchangeRelease(old, new uintptr) uintptr

CompareExchangeRelease atomically compares and swaps with release ordering.

func (*Uintptr) Load

func (a *Uintptr) Load() uintptr

Load atomically loads and returns the value with relaxed ordering.

func (*Uintptr) LoadAcquire

func (a *Uintptr) LoadAcquire() uintptr

LoadAcquire atomically loads and returns the value with acquire ordering.

func (*Uintptr) LoadRelaxed

func (a *Uintptr) LoadRelaxed() uintptr

LoadRelaxed atomically loads and returns the value with relaxed ordering.

func (*Uintptr) Max

func (a *Uintptr) Max(val uintptr) uintptr

Max atomically stores max(*addr, val) and returns the old value with acquire-release ordering.

func (*Uintptr) MaxRelaxed

func (a *Uintptr) MaxRelaxed(val uintptr) uintptr

MaxRelaxed atomically stores max(*addr, val) and returns the old value with relaxed ordering.

func (*Uintptr) Min

func (a *Uintptr) Min(val uintptr) uintptr

Min atomically stores min(*addr, val) and returns the old value with acquire-release ordering.

func (*Uintptr) MinRelaxed

func (a *Uintptr) MinRelaxed(val uintptr) uintptr

MinRelaxed atomically stores min(*addr, val) and returns the old value with relaxed ordering.

func (*Uintptr) Or

func (a *Uintptr) Or(mask uintptr) uintptr

Or atomically performs bitwise OR and returns the old value with acquire-release ordering.

func (*Uintptr) OrAcqRel

func (a *Uintptr) OrAcqRel(mask uintptr) uintptr

OrAcqRel atomically performs bitwise OR with acquire-release ordering.

func (*Uintptr) OrAcquire

func (a *Uintptr) OrAcquire(mask uintptr) uintptr

OrAcquire atomically performs bitwise OR with acquire ordering.

func (*Uintptr) OrRelaxed

func (a *Uintptr) OrRelaxed(mask uintptr) uintptr

OrRelaxed atomically performs bitwise OR with relaxed ordering.

func (*Uintptr) OrRelease

func (a *Uintptr) OrRelease(mask uintptr) uintptr

OrRelease atomically performs bitwise OR with release ordering.

func (*Uintptr) Store

func (a *Uintptr) Store(val uintptr)

Store atomically stores val with relaxed ordering.

func (*Uintptr) StoreRelaxed

func (a *Uintptr) StoreRelaxed(val uintptr)

StoreRelaxed atomically stores val with relaxed ordering.

func (*Uintptr) StoreRelease

func (a *Uintptr) StoreRelease(val uintptr)

StoreRelease atomically stores val with release ordering.

func (*Uintptr) Sub

func (a *Uintptr) Sub(delta uintptr) uintptr

Sub atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Uintptr) SubAcqRel

func (a *Uintptr) SubAcqRel(delta uintptr) uintptr

SubAcqRel atomically subtracts delta and returns the new value with acquire-release ordering.

func (*Uintptr) SubAcquire

func (a *Uintptr) SubAcquire(delta uintptr) uintptr

SubAcquire atomically subtracts delta and returns the new value with acquire ordering.

func (*Uintptr) SubRelaxed

func (a *Uintptr) SubRelaxed(delta uintptr) uintptr

SubRelaxed atomically subtracts delta and returns the new value with relaxed ordering.

func (*Uintptr) SubRelease

func (a *Uintptr) SubRelease(delta uintptr) uintptr

SubRelease atomically subtracts delta and returns the new value with release ordering.

func (*Uintptr) Swap

func (a *Uintptr) Swap(new uintptr) uintptr

Swap atomically swaps the value and returns the old value with acquire-release ordering.

func (*Uintptr) SwapAcqRel

func (a *Uintptr) SwapAcqRel(new uintptr) uintptr

SwapAcqRel atomically swaps the value and returns the old value with acquire-release ordering.

func (*Uintptr) SwapAcquire

func (a *Uintptr) SwapAcquire(new uintptr) uintptr

SwapAcquire atomically swaps the value and returns the old value with acquire ordering.

func (*Uintptr) SwapRelaxed

func (a *Uintptr) SwapRelaxed(new uintptr) uintptr

SwapRelaxed atomically swaps the value and returns the old value with relaxed ordering.

func (*Uintptr) SwapRelease

func (a *Uintptr) SwapRelease(new uintptr) uintptr

SwapRelease atomically swaps the value and returns the old value with release ordering.

func (*Uintptr) Xor

func (a *Uintptr) Xor(mask uintptr) uintptr

Xor atomically performs bitwise XOR and returns the old value with acquire-release ordering.

func (*Uintptr) XorAcqRel

func (a *Uintptr) XorAcqRel(mask uintptr) uintptr

XorAcqRel atomically performs bitwise XOR with acquire-release ordering.

func (*Uintptr) XorAcquire

func (a *Uintptr) XorAcquire(mask uintptr) uintptr

XorAcquire atomically performs bitwise XOR with acquire ordering.

func (*Uintptr) XorRelaxed

func (a *Uintptr) XorRelaxed(mask uintptr) uintptr

XorRelaxed atomically performs bitwise XOR with relaxed ordering.

func (*Uintptr) XorRelease

func (a *Uintptr) XorRelease(mask uintptr) uintptr

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.

Directories

Path Synopsis
internal
arch
Package arch provides architecture-specific atomic primitives with explicit memory ordering.
Package arch provides architecture-specific atomic primitives with explicit memory ordering.

Jump to

Keyboard shortcuts

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