Documentation ¶
Overview ¶
Package atomic provides low-level atomic memory primitives useful for implementing synchronization algorithms.
Index ¶
- func AddInt32(addr *int32, delta int32) (new int32)
- func AddInt64(addr *int64, delta int64) (new int64)
- func AddUint32(addr *uint32, delta uint32) (new uint32)
- func AddUint64(addr *uint64, delta uint64) (new uint64)
- func AddUintptr(addr *uintptr, delta uintptr) (new uintptr)
- func CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool)
- func CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool)
- func CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)
- func CompareAndSwapUint32(addr *uint32, old, new uint32) (swapped bool)
- func CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool)
- func CompareAndSwapUintptr(addr *uintptr, old, new uintptr) (swapped bool)
- func LoadInt32(addr *int32) (val int32)
- func LoadInt64(addr *int64) (val int64)
- func LoadPointer(addr *unsafe.Pointer) (val unsafe.Pointer)
- func LoadUint32(addr *uint32) (val uint32)
- func LoadUint64(addr *uint64) (val uint64)
- func LoadUintptr(addr *uintptr) (val uintptr)
- func StoreInt32(addr *int32, val int32)
- func StoreInt64(addr *int64, val int64)
- func StorePointer(addr *unsafe.Pointer, val unsafe.Pointer)
- func StoreUint32(addr *uint32, val uint32)
- func StoreUint64(addr *uint64, val uint64)
- func StoreUintptr(addr *uintptr, val uintptr)
- func SwapInt32(addr *int32, new int32) (old int32)
- func SwapInt64(addr *int64, new int64) (old int64)
- func SwapPointer(addr *unsafe.Pointer, new unsafe.Pointer) (old unsafe.Pointer)
- func SwapUint32(addr *uint32, new uint32) (old uint32)
- func SwapUint64(addr *uint64, new uint64) (old uint64)
- func SwapUintptr(addr *uintptr, new uintptr) (old uintptr)
- type AddFunc
- type Bool
- type Bytes
- type EqualFunc
- type Float32
- type Float64
- type Int16
- type Int32
- type Int64
- type Int8
- type Pointer
- type String
- type Uint16
- type Uint32
- type Uint64
- type Uint8
- type Uintptr
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUint32 ¶
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)).
func AddUint64 ¶
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)).
func AddUintptr ¶
AddUintptr atomically adds delta to *addr and returns the new value.
func CompareAndSwapInt32 ¶
CompareAndSwapInt32 executes the compare-and-swap operation for an int32 value.
func CompareAndSwapInt64 ¶
CompareAndSwapInt64 executes the compare-and-swap operation for an int64 value.
func CompareAndSwapPointer ¶
CompareAndSwapPointer executes the compare-and-swap operation for a unsafe.Pointer value.
func CompareAndSwapUint32 ¶
CompareAndSwapUint32 executes the compare-and-swap operation for a uint32 value.
func CompareAndSwapUint64 ¶
CompareAndSwapUint64 executes the compare-and-swap operation for a uint64 value.
func CompareAndSwapUintptr ¶
CompareAndSwapUintptr executes the compare-and-swap operation for a uintptr value.
func LoadPointer ¶
LoadPointer atomically loads *addr.
func LoadUintptr ¶
LoadUintptr atomically loads *addr.
func StoreInt32 ¶
StoreInt32 atomically stores val into *addr.
func StoreInt64 ¶
StoreInt64 atomically stores val into *addr.
func StorePointer ¶
StorePointer atomically stores val into *addr.
func StoreUint32 ¶
StoreUint32 atomically stores val into *addr.
func StoreUint64 ¶
StoreUint64 atomically stores val into *addr.
func StoreUintptr ¶
StoreUintptr atomically stores val into *addr.
func SwapPointer ¶
SwapPointer atomically stores new into *addr and returns the previous *addr value.
func SwapUint32 ¶
SwapUint32 atomically stores new into *addr and returns the previous *addr value.
func SwapUint64 ¶
SwapUint64 atomically stores new into *addr and returns the previous *addr value.
func SwapUintptr ¶
SwapUintptr atomically stores new into *addr and returns the previous *addr value.
Types ¶
type AddFunc ¶
type AddFunc func(old, delta interface{}) (new interface{})
AddFunc is a add function.
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool represents an bool.
func (*Bool) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an bool value.
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
Bytes represents an []byte.
func (*Bytes) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an []byte value.
type EqualFunc ¶
type EqualFunc func(old, load interface{}) (equal bool)
EqualFunc is a equal function.
type Float32 ¶
type Float32 struct {
// contains filtered or unexported fields
}
Float32 represents an float32.
func (*Float32) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an float32 value.
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 represents an float64.
func (*Float64) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an float64 value.
type Int16 ¶
type Int16 struct {
// contains filtered or unexported fields
}
Int16 represents an int16.
func (*Int16) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an int16 value.
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 represents an int32.
func (*Int32) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an int32 value.
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 represents an int64.
func (*Int64) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an int32 value.
type Int8 ¶
type Int8 struct {
// contains filtered or unexported fields
}
Int8 represents an int8.
func (*Int8) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an int16 value.
type Pointer ¶
type Pointer struct {
// contains filtered or unexported fields
}
Pointer represents an unsafe.Pointer.
func (*Pointer) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an uint64 value.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String represents an string.
func (*String) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an string value.
type Uint16 ¶
type Uint16 struct {
// contains filtered or unexported fields
}
Uint16 represents an uint16.
func (*Uint16) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an uint16 value.
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 represents an uint32.
func (*Uint32) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an uint32 value.
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
Uint64 represents an uint64.
func (*Uint64) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an uint64 value.
type Uint8 ¶
type Uint8 struct {
// contains filtered or unexported fields
}
Uint8 represents an uint8.
func (*Uint8) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an uint8 value.
type Uintptr ¶
type Uintptr struct {
// contains filtered or unexported fields
}
Uintptr represents an uintptr.
func (*Uintptr) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an uintptr value.
type Value ¶
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.
func (*Value) Add ¶
func (v *Value) Add(delta interface{}) (new interface{})
Add atomically adds delta to *addr and returns the new value.
func (*Value) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an interface{} value.
func (*Value) Load ¶
func (v *Value) Load() (x interface{})
Load returns the value set by the most recent Store. It returns nil if there has been no call to Store for this Value.