Namespace: go.std.sync.atomic
v1.0Contents
Summary
Provides a low-level interface to the sync/atomic package.
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".
Index
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
(None.)
Variables
-
(None.)
Functions, Macros, and Special Forms
-
CompareAndSwapPointer
Function v1.0(CompareAndSwapPointer addr old new)
CompareAndSwapPointer executes the compare-and-swap operation for a unsafe.Pointer value.
Go input arguments: (addr *unsafe.Pointer, old unsafe.Pointer, new unsafe.Pointer)
Go returns: bool
Joker input arguments: [^go.std.unsafe/*Pointer addr, ^go.std.unsafe/Pointer old, ^go.std.unsafe/Pointer new]
Joker returns: ^Boolean swapped -
LoadPointer
Function v1.0(LoadPointer addr)
LoadPointer atomically loads *addr.
Go input arguments: (addr *unsafe.Pointer)
Go returns: unsafe.Pointer
Joker input arguments: [^go.std.unsafe/*Pointer addr]
Joker returns: ^go.std.unsafe/Pointer val -
StorePointer
Function v1.0(StorePointer addr val)
StorePointer atomically stores val into *addr.
Go input arguments: (addr *unsafe.Pointer, val unsafe.Pointer)
Joker input arguments: [^go.std.unsafe/*Pointer addr, ^go.std.unsafe/Pointer val] -
SwapPointer
Function v1.0(SwapPointer addr new)
SwapPointer atomically stores new into *addr and returns the previous *addr value.
Go input arguments: (addr *unsafe.Pointer, new unsafe.Pointer)
Go returns: unsafe.Pointer
Joker input arguments: [^go.std.unsafe/*Pointer addr, ^go.std.unsafe/Pointer new]
Joker returns: ^go.std.unsafe/Pointer old
Types
-
*Value
Concrete Type v1.0A 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.
-
CompareAndSwap
Receiver for *Value v1.0([old new])
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).
-
Load
Receiver for *Value v1.0([])
Load returns the value set by the most recent Store.
It returns nil if there has been no call to Store for this Value.
-
Store
Receiver for *Value v1.0([val])
Store sets the value of the Value to x.
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).
-
Swap
Receiver for *Value v1.0([new])
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).
-
Value
Concrete Type v1.0A 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.
-
arrayOfValue
Concrete Type v1.0A 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.