go2hx

manual

github

Module: stdgo.sync.atomic_

(view library index)

Overview

Package atomic provides low-level atomic memory primitives useful for implementing synchronization algorithms.

These functions require great care to be used correctly. Except for special, low-level applications, synchronization is better done with channels or the facilities of the [sync] package. Share memory by communicating; don't communicate by sharing memory.

The swap operation, implemented by the SwapT functions, is the atomic equivalent of:

	old = *addr
	*addr = new
	return old

The compare-and-swap operation, implemented by the CompareAndSwapT functions, is the atomic equivalent of:

	if *addr == old {
		*addr = new
		return true
	}
	return false

The add operation, implemented by the AddT functions, is the atomic equivalent of:

	*addr += delta
	return *addr

The load and store operations, implemented by the LoadT and StoreT functions, are the atomic equivalents of "return \addr" and "\addr = val".

In the terminology of the Go memory model, if the effect of an atomic operation A is observed by atomic operation B, then A “synchronizes before” B. Additionally, all the atomic operations executed in a program behave as though executed in some sequentially consistent order. This definition provides the same semantics as C++'s sequentially consistent atomics and Java's volatile variables.

Index

Variables

import stdgo.sync.atomic_.Atomic_
var __24:stdgo.Ref<stdgo.sync.atomic_.Pointer_<stdgo.GoInt>>

For testing *Pointer[T]'s methods can be inlined. Keep in sync with cmd/compile/internal/test/inl_test.go:TestIntendedInlining.

var _firstStoreInProgress:stdgo.GoByte

Functions

import stdgo.sync.atomic_.Atomic_

function _b32

function _b32(_b:Bool):stdgo.GoUInt32

b32 returns a uint32 0 or 1 representing b.

(view code)

function _runtime_procPin

function _runtime_procPin():stdgo.GoInt

Disable/enable preemption, implemented in runtime.

(view code)

function _runtime_procUnpin

function _runtime_procUnpin():Void

(view code)

function addInt32

function addInt32(_addr:stdgo.Pointer<stdgo.GoInt32>, _delta:stdgo.GoInt32):stdgo.GoInt32

AddInt32 atomically adds delta to *addr and returns the new value. Consider using the more ergonomic and less error-prone [Int32.Add] instead.

(view code)

function addInt64

function addInt64(_addr:stdgo.Pointer<stdgo.GoInt64>, _delta:stdgo.GoInt64):stdgo.GoInt64

AddInt64 atomically adds delta to *addr and returns the new value. Consider using the more ergonomic and less error-prone [Int64.Add] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function addUint32

function addUint32(_addr:stdgo.Pointer<stdgo.GoUInt32>, _delta:stdgo.GoUInt32):stdgo.GoUInt32

AddUint32 atomically adds delta to *addr and returns the new value. To subtract a signed positive constant value c from x, do AddUint32(&x, ^uint32(c-1)). In particular, to decrement x, do AddUint32(&x, ^uint32(0)). Consider using the more ergonomic and less error-prone [Uint32.Add] instead.

(view code)

function addUint64

function addUint64(_addr:stdgo.Pointer<stdgo.GoUInt64>, _delta:stdgo.GoUInt64):stdgo.GoUInt64

AddUint64 atomically adds delta to *addr and returns the new value. To subtract a signed positive constant value c from x, do AddUint64(&x, ^uint64(c-1)). In particular, to decrement x, do AddUint64(&x, ^uint64(0)). Consider using the more ergonomic and less error-prone [Uint64.Add] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function addUintptr

function addUintptr(_addr:stdgo.Pointer<stdgo.GoUIntptr>, _delta:stdgo.GoUIntptr):stdgo.GoUIntptr

AddUintptr atomically adds delta to *addr and returns the new value. Consider using the more ergonomic and less error-prone [Uintptr.Add] instead.

(view code)

function compareAndSwapInt32

function compareAndSwapInt32(_addr:stdgo.Pointer<stdgo.GoInt32>, _old:stdgo.GoInt32, _new:stdgo.GoInt32):Bool

CompareAndSwapInt32 executes the compare-and-swap operation for an int32 value. Consider using the more ergonomic and less error-prone [Int32.CompareAndSwap] instead.

(view code)

function compareAndSwapInt64

function compareAndSwapInt64(_addr:stdgo.Pointer<stdgo.GoInt64>, _old:stdgo.GoInt64, _new:stdgo.GoInt64):Bool

CompareAndSwapInt64 executes the compare-and-swap operation for an int64 value. Consider using the more ergonomic and less error-prone [Int64.CompareAndSwap] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function compareAndSwapPointer

function compareAndSwapPointer(_addr:stdgo.Pointer<stdgo.unsafe.UnsafePointer>, _old:stdgo.unsafe.UnsafePointer, _new:stdgo.unsafe.UnsafePointer):Bool

CompareAndSwapPointer executes the compare-and-swap operation for a unsafe.Pointer value. Consider using the more ergonomic and less error-prone [Pointer.CompareAndSwap] instead.

(view code)

function compareAndSwapUint32

function compareAndSwapUint32(_addr:stdgo.Pointer<stdgo.GoUInt32>, _old:stdgo.GoUInt32, _new:stdgo.GoUInt32):Bool

CompareAndSwapUint32 executes the compare-and-swap operation for a uint32 value. Consider using the more ergonomic and less error-prone [Uint32.CompareAndSwap] instead.

(view code)

function compareAndSwapUint64

function compareAndSwapUint64(_addr:stdgo.Pointer<stdgo.GoUInt64>, _old:stdgo.GoUInt64, _new:stdgo.GoUInt64):Bool

CompareAndSwapUint64 executes the compare-and-swap operation for a uint64 value. Consider using the more ergonomic and less error-prone [Uint64.CompareAndSwap] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function compareAndSwapUintptr

function compareAndSwapUintptr(_addr:stdgo.Pointer<stdgo.GoUIntptr>, _old:stdgo.GoUIntptr, _new:stdgo.GoUIntptr):Bool

CompareAndSwapUintptr executes the compare-and-swap operation for a uintptr value. Consider using the more ergonomic and less error-prone [Uintptr.CompareAndSwap] instead.

(view code)

function loadInt32

function loadInt32(_addr:stdgo.Pointer<stdgo.GoInt32>):stdgo.GoInt32

LoadInt32 atomically loads *addr. Consider using the more ergonomic and less error-prone [Int32.Load] instead.

(view code)

function loadInt64

function loadInt64(_addr:stdgo.Pointer<stdgo.GoInt64>):stdgo.GoInt64

LoadInt64 atomically loads *addr. Consider using the more ergonomic and less error-prone [Int64.Load] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function loadPointer

function loadPointer(_addr:stdgo.Pointer<stdgo.unsafe.UnsafePointer>):stdgo.unsafe.UnsafePointer

LoadPointer atomically loads *addr. Consider using the more ergonomic and less error-prone [Pointer.Load] instead.

(view code)

function loadUint32

function loadUint32(_addr:stdgo.Pointer<stdgo.GoUInt32>):stdgo.GoUInt32

LoadUint32 atomically loads *addr. Consider using the more ergonomic and less error-prone [Uint32.Load] instead.

(view code)

function loadUint64

function loadUint64(_addr:stdgo.Pointer<stdgo.GoUInt64>):stdgo.GoUInt64

LoadUint64 atomically loads *addr. Consider using the more ergonomic and less error-prone [Uint64.Load] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function loadUintptr

function loadUintptr(_addr:stdgo.Pointer<stdgo.GoUIntptr>):stdgo.GoUIntptr

LoadUintptr atomically loads *addr. Consider using the more ergonomic and less error-prone [Uintptr.Load] instead.

(view code)

function storeInt32

function storeInt32(_addr:stdgo.Pointer<stdgo.GoInt32>, _val:stdgo.GoInt32):Void

StoreInt32 atomically stores val into *addr. Consider using the more ergonomic and less error-prone [Int32.Store] instead.

(view code)

function storeInt64

function storeInt64(_addr:stdgo.Pointer<stdgo.GoInt64>, _val:stdgo.GoInt64):Void

StoreInt64 atomically stores val into *addr. Consider using the more ergonomic and less error-prone [Int64.Store] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function storePointer

function storePointer(_addr:stdgo.Pointer<stdgo.unsafe.UnsafePointer>, _val:stdgo.unsafe.UnsafePointer):Void

StorePointer atomically stores val into *addr. Consider using the more ergonomic and less error-prone [Pointer.Store] instead.

(view code)

function storeUint32

function storeUint32(_addr:stdgo.Pointer<stdgo.GoUInt32>, _val:stdgo.GoUInt32):Void

StoreUint32 atomically stores val into *addr. Consider using the more ergonomic and less error-prone [Uint32.Store] instead.

(view code)

function storeUint64

function storeUint64(_addr:stdgo.Pointer<stdgo.GoUInt64>, _val:stdgo.GoUInt64):Void

StoreUint64 atomically stores val into *addr. Consider using the more ergonomic and less error-prone [Uint64.Store] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function storeUintptr

function storeUintptr(_addr:stdgo.Pointer<stdgo.GoUIntptr>, _val:stdgo.GoUIntptr):Void

StoreUintptr atomically stores val into *addr. Consider using the more ergonomic and less error-prone [Uintptr.Store] instead.

(view code)

function swapInt32

function swapInt32(_addr:stdgo.Pointer<stdgo.GoInt32>, _new:stdgo.GoInt32):stdgo.GoInt32

SwapInt32 atomically stores new into \addr and returns the previous \addr value. Consider using the more ergonomic and less error-prone [Int32.Swap] instead.

(view code)

function swapInt64

function swapInt64(_addr:stdgo.Pointer<stdgo.GoInt64>, _new:stdgo.GoInt64):stdgo.GoInt64

SwapInt64 atomically stores new into \addr and returns the previous \addr value. Consider using the more ergonomic and less error-prone [Int64.Swap] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function swapPointer

function swapPointer(_addr:stdgo.Pointer<stdgo.unsafe.UnsafePointer>, _new:stdgo.unsafe.UnsafePointer):stdgo.unsafe.UnsafePointer

SwapPointer atomically stores new into \addr and returns the previous \addr value. Consider using the more ergonomic and less error-prone [Pointer.Swap] instead.

(view code)

function swapUint32

function swapUint32(_addr:stdgo.Pointer<stdgo.GoUInt32>, _new:stdgo.GoUInt32):stdgo.GoUInt32

SwapUint32 atomically stores new into \addr and returns the previous \addr value. Consider using the more ergonomic and less error-prone [Uint32.Swap] instead.

(view code)

function swapUint64

function swapUint64(_addr:stdgo.Pointer<stdgo.GoUInt64>, _new:stdgo.GoUInt64):stdgo.GoUInt64

SwapUint64 atomically stores new into \addr and returns the previous \addr value. Consider using the more ergonomic and less error-prone [Uint64.Swap] instead (particularly if you target 32-bit platforms; see the bugs section).

(view code)

function swapUintptr

function swapUintptr(_addr:stdgo.Pointer<stdgo.GoUIntptr>, _new:stdgo.GoUIntptr):stdgo.GoUIntptr

SwapUintptr atomically stores new into \addr and returns the previous \addr value. Consider using the more ergonomic and less error-prone [Uintptr.Swap] instead.

(view code)

Classes

import stdgo.sync.atomic_.*

class Bool_

A Bool is an atomic boolean value. The zero value is false.

var __2:stdgo.sync.atomic_.T_noCopy
var _v:stdgo.GoUInt32

Bool_ function new

function new(?__2:stdgo.sync.atomic_.T_noCopy, ?_v:stdgo.GoUInt32):Void

(view code)

Bool_ function compareAndSwap

function compareAndSwap( _old:Bool, _new:Bool):Bool

CompareAndSwap executes the compare-and-swap operation for the boolean value x.

(view code)

Bool_ function load

function load():Bool

Load atomically loads and returns the value stored in x.

(view code)

Bool_ function store

function store( _val:Bool):Void

Store atomically stores val into x.

(view code)

Bool_ function swap

function swap( _new:Bool):Bool

Swap atomically stores new into x and returns the previous value.

(view code)

class Int32

An Int32 is an atomic int32. The zero value is zero.

var __8:stdgo.sync.atomic_.T_noCopy
var _v:stdgo.GoInt32

Int32 function new

function new(?__8:stdgo.sync.atomic_.T_noCopy, ?_v:stdgo.GoInt32):Void

(view code)

Int32 function add

function add( _delta:stdgo.GoInt32):stdgo.GoInt32

Add atomically adds delta to x and returns the new value.

(view code)

Int32 function compareAndSwap

function compareAndSwap( _old:stdgo.GoInt32, _new:stdgo.GoInt32):Bool

CompareAndSwap executes the compare-and-swap operation for x.

(view code)

Int32 function load

function load():stdgo.GoInt32

Load atomically loads and returns the value stored in x.

(view code)

Int32 function store

function store( _val:stdgo.GoInt32):Void

Store atomically stores val into x.

(view code)

Int32 function swap

function swap( _new:stdgo.GoInt32):stdgo.GoInt32

Swap atomically stores new into x and returns the previous value.

(view code)

class Int64_

An Int64 is an atomic int64. The zero value is zero.

var __11:stdgo.sync.atomic_.T_noCopy
var __12:stdgo.sync.atomic_.T_align64
var _v:stdgo.GoInt64

Int64_ function new

function new(?__11:stdgo.sync.atomic_.T_noCopy, ?__12:stdgo.sync.atomic_.T_align64, ?_v:stdgo.GoInt64):Void

(view code)

Int64_ function add

function add( _delta:stdgo.GoInt64):stdgo.GoInt64

Add atomically adds delta to x and returns the new value.

(view code)

Int64_ function compareAndSwap

function compareAndSwap( _old:stdgo.GoInt64, _new:stdgo.GoInt64):Bool

CompareAndSwap executes the compare-and-swap operation for x.

(view code)

Int64_ function load

function load():stdgo.GoInt64

Load atomically loads and returns the value stored in x.

(view code)

Int64_ function store

function store( _val:stdgo.GoInt64):Void

Store atomically stores val into x.

(view code)

Int64_ function swap

function swap( _new:stdgo.GoInt64):stdgo.GoInt64

Swap atomically stores new into x and returns the previous value.

(view code)

class Pointer_

A Pointer is an atomic pointer of type \T. The zero value is a nil \T.

var __5:stdgo.GoArray<stdgo.Ref<stdgo.sync.atomic_.Pointer_.T_>>

Mention \T in a field to disallow conversion between Pointer types. See go.dev/issue/56603 for more details. Use \T, not T, to avoid spurious recursive type definition errors.

var __6:stdgo.sync.atomic_.T_noCopy
var _v:stdgo.unsafe.UnsafePointer

Pointer_ function new

function new(?__5:stdgo.GoArray<stdgo.Ref<stdgo.sync.atomic_.Pointer_.T_>>, ?__6:stdgo.sync.atomic_.T_noCopy, ?_v:stdgo.unsafe.UnsafePointer):Void

(view code)

Pointer_ function compareAndSwap

function compareAndSwap( __generic__0:compareAndSwap.T_, _old:stdgo.Ref<compareAndSwap.T_>, _new:stdgo.Ref<compareAndSwap.T_>):Bool

CompareAndSwap executes the compare-and-swap operation for x.

Pointer_ function load

function load( __generic__0:load.T_):stdgo.Ref<load.T_>

Load atomically loads and returns the value stored in x.

Pointer_ function store

function store( __generic__0:store.T_, _val:stdgo.Ref<store.T_>):Void

Store atomically stores val into x.

Pointer_ function swap

function swap( __generic__0:swap.T_, _new:stdgo.Ref<swap.T_>):stdgo.Ref<swap.T_>

Swap atomically stores new into x and returns the previous value.

class Uint32

A Uint32 is an atomic uint32. The zero value is zero.

var __13:stdgo.sync.atomic_.T_noCopy
var _v:stdgo.GoUInt32

Uint32 function new

function new(?__13:stdgo.sync.atomic_.T_noCopy, ?_v:stdgo.GoUInt32):Void

(view code)

Uint32 function add

function add( _delta:stdgo.GoUInt32):stdgo.GoUInt32

Add atomically adds delta to x and returns the new value.

(view code)

Uint32 function compareAndSwap

function compareAndSwap( _old:stdgo.GoUInt32, _new:stdgo.GoUInt32):Bool

CompareAndSwap executes the compare-and-swap operation for x.

(view code)

Uint32 function load

function load():stdgo.GoUInt32

Load atomically loads and returns the value stored in x.

(view code)

Uint32 function store

function store( _val:stdgo.GoUInt32):Void

Store atomically stores val into x.

(view code)

Uint32 function swap

function swap( _new:stdgo.GoUInt32):stdgo.GoUInt32

Swap atomically stores new into x and returns the previous value.

(view code)

class Uint64

A Uint64 is an atomic uint64. The zero value is zero.

var __16:stdgo.sync.atomic_.T_noCopy
var __17:stdgo.sync.atomic_.T_align64
var _v:stdgo.GoUInt64

Uint64 function new

function new(?__16:stdgo.sync.atomic_.T_noCopy, ?__17:stdgo.sync.atomic_.T_align64, ?_v:stdgo.GoUInt64):Void

(view code)

Uint64 function add

function add( _delta:stdgo.GoUInt64):stdgo.GoUInt64

Add atomically adds delta to x and returns the new value.

(view code)

Uint64 function compareAndSwap

function compareAndSwap( _old:stdgo.GoUInt64, _new:stdgo.GoUInt64):Bool

CompareAndSwap executes the compare-and-swap operation for x.

(view code)

Uint64 function load

function load():stdgo.GoUInt64

Load atomically loads and returns the value stored in x.

(view code)

Uint64 function store

function store( _val:stdgo.GoUInt64):Void

Store atomically stores val into x.

(view code)

Uint64 function swap

function swap( _new:stdgo.GoUInt64):stdgo.GoUInt64

Swap atomically stores new into x and returns the previous value.

(view code)

class Uintptr

A Uintptr is an atomic uintptr. The zero value is zero.

var __19:stdgo.sync.atomic_.T_noCopy
var _v:stdgo.GoUIntptr

Uintptr function new

function new(?__19:stdgo.sync.atomic_.T_noCopy, ?_v:stdgo.GoUIntptr):Void

(view code)

Uintptr function add

function add( _delta:stdgo.GoUIntptr):stdgo.GoUIntptr

Add atomically adds delta to x and returns the new value.

(view code)

Uintptr function compareAndSwap

function compareAndSwap( _old:stdgo.GoUIntptr, _new:stdgo.GoUIntptr):Bool

CompareAndSwap executes the compare-and-swap operation for x.

(view code)

Uintptr function load

function load():stdgo.GoUIntptr

Load atomically loads and returns the value stored in x.

(view code)

Uintptr function store

function store( _val:stdgo.GoUIntptr):Void

Store atomically stores val into x.

(view code)

Uintptr function swap

function swap( _new:stdgo.GoUIntptr):stdgo.GoUIntptr

Swap atomically stores new into x and returns the previous value.

(view code)

class Value

A Value provides an atomic load and store of a consistently typed value. The zero value for a Value returns nil from Load. Once Store has been called, a Value must not be copied.

A Value must not be copied after first use.

var _v:stdgo.AnyInterface

Value function new

function new(?_v:stdgo.AnyInterface):Void

(view code)

Value function compareAndSwap

function compareAndSwap( _old:stdgo.AnyInterface, _new:stdgo.AnyInterface):Bool

CompareAndSwap executes the compare-and-swap operation for the Value.

All calls to CompareAndSwap for a given Value must use values of the same concrete type. CompareAndSwap of an inconsistent type panics, as does CompareAndSwap(old, nil).

(view code)

Value function load

function load():stdgo.AnyInterface

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

(view code)

Value function store

function store( _val:stdgo.AnyInterface):Void

Store sets the value of the Value v to val. All calls to Store for a given Value must use values of the same concrete type. Store of an inconsistent type panics, as does Store(nil).

(view code)

Value function swap

function swap( _new:stdgo.AnyInterface):stdgo.AnyInterface

Swap stores new into Value and returns the previous value. It returns nil if the Value is empty.

All calls to Swap for a given Value must use values of the same concrete type. Swap of an inconsistent type panics, as does Swap(nil).

(view code)