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".
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
- *Bool
- *Int32
- *Int64
- *Uint32
- *Uint64
- *Uintptr
- *Value
- Bool
- CompareAndSwapPointer
- Int32
- Int64
- LoadPointer
- StorePointer
- SwapPointer
- Uint32
- Uint64
- Uintptr
- Value
- arrayOfBool
- arrayOfInt32
- arrayOfInt64
- arrayOfUint32
- arrayOfUint64
- arrayOfUintptr
- arrayOfValue
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
-
*Bool
Concrete Type v1.0A Bool is an atomic boolean value.
The zero value is false.
-
CompareAndSwap
Receiver for *Bool v1.0([old new])
CompareAndSwap executes the compare-and-swap operation for the boolean value x.
-
Load
Receiver for *Bool v1.0([])
Load atomically loads and returns the value stored in x.
-
Store
Receiver for *Bool v1.0([val])
Store atomically stores val into x.
-
Swap
Receiver for *Bool v1.0([new])
Swap atomically stores new into x and returns the previous value.
-
*Int32
Concrete Type v1.0An Int32 is an atomic int32. The zero value is zero.
-
Add
Receiver for *Int32 v1.0([delta])
Add atomically adds delta to x and returns the new value.
-
CompareAndSwap
Receiver for *Int32 v1.0([old new])
CompareAndSwap executes the compare-and-swap operation for x.
-
Load
Receiver for *Int32 v1.0([])
Load atomically loads and returns the value stored in x.
-
Store
Receiver for *Int32 v1.0([val])
Store atomically stores val into x.
-
Swap
Receiver for *Int32 v1.0([new])
Swap atomically stores new into x and returns the previous value.
-
*Int64
Concrete Type v1.0An Int64 is an atomic int64. The zero value is zero.
-
Add
Receiver for *Int64 v1.0([delta])
Add atomically adds delta to x and returns the new value.
-
CompareAndSwap
Receiver for *Int64 v1.0([old new])
CompareAndSwap executes the compare-and-swap operation for x.
-
Load
Receiver for *Int64 v1.0([])
Load atomically loads and returns the value stored in x.
-
Store
Receiver for *Int64 v1.0([val])
Store atomically stores val into x.
-
Swap
Receiver for *Int64 v1.0([new])
Swap atomically stores new into x and returns the previous value.
-
*Uint32
Concrete Type v1.0An Uint32 is an atomic uint32. The zero value is zero.
-
Add
Receiver for *Uint32 v1.0([delta])
Add atomically adds delta to x and returns the new value.
-
CompareAndSwap
Receiver for *Uint32 v1.0([old new])
CompareAndSwap executes the compare-and-swap operation for x.
-
Load
Receiver for *Uint32 v1.0([])
Load atomically loads and returns the value stored in x.
-
Store
Receiver for *Uint32 v1.0([val])
Store atomically stores val into x.
-
Swap
Receiver for *Uint32 v1.0([new])
Swap atomically stores new into x and returns the previous value.
-
*Uint64
Concrete Type v1.0An Uint64 is an atomic uint64. The zero value is zero.
-
Add
Receiver for *Uint64 v1.0([delta])
Add atomically adds delta to x and returns the new value.
-
CompareAndSwap
Receiver for *Uint64 v1.0([old new])
CompareAndSwap executes the compare-and-swap operation for x.
-
Load
Receiver for *Uint64 v1.0([])
Load atomically loads and returns the value stored in x.
-
Store
Receiver for *Uint64 v1.0([val])
Store atomically stores val into x.
-
Swap
Receiver for *Uint64 v1.0([new])
Swap atomically stores new into x and returns the previous value.
-
*Uintptr
Concrete Type v1.0An Uintptr is an atomic uintptr. The zero value is zero.
-
Add
Receiver for *Uintptr v1.0([delta])
Add atomically adds delta to x and returns the new value.
-
CompareAndSwap
Receiver for *Uintptr v1.0([old new])
CompareAndSwap executes the compare-and-swap operation for x.
-
Load
Receiver for *Uintptr v1.0([])
Load atomically loads and returns the value stored in x.
-
Store
Receiver for *Uintptr v1.0([val])
Store atomically stores val into x.
-
Swap
Receiver for *Uintptr v1.0([new])
Swap atomically stores new into x and returns the previous value.
-
*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).
-
Bool
Concrete Type v1.0A Bool is an atomic boolean value.
The zero value is false.
-
Int32
Concrete Type v1.0An Int32 is an atomic int32. The zero value is zero.
-
Int64
Concrete Type v1.0An Int64 is an atomic int64. The zero value is zero.
-
Uint32
Concrete Type v1.0An Uint32 is an atomic uint32. The zero value is zero.
-
Uint64
Concrete Type v1.0An Uint64 is an atomic uint64. The zero value is zero.
-
Uintptr
Concrete Type v1.0An Uintptr is an atomic uintptr. The zero value is zero.
-
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.
-
arrayOfBool
Concrete Type v1.0A Bool is an atomic boolean value.
The zero value is false.
-
arrayOfInt32
Concrete Type v1.0An Int32 is an atomic int32. The zero value is zero.
-
arrayOfInt64
Concrete Type v1.0An Int64 is an atomic int64. The zero value is zero.
-
arrayOfUint32
Concrete Type v1.0An Uint32 is an atomic uint32. The zero value is zero.
-
arrayOfUint64
Concrete Type v1.0An Uint64 is an atomic uint64. The zero value is zero.
-
arrayOfUintptr
Concrete Type v1.0An Uintptr is an atomic uintptr. The zero value is zero.
-
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.