Copyright 2011 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
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".
package atomic

import (
	
)
BUG(rsc): On 386, the 64-bit functions use instructions unavailable before the Pentium MMX. On non-Linux ARM, the 64-bit functions use instructions unavailable before the ARMv6k core. On ARM, 386, and 32-bit MIPS, it is the caller's responsibility to arrange for 64-bit alignment of 64-bit words accessed atomically. The first word in a variable or in an allocated struct, array, or slice can be relied upon to be 64-bit aligned.
SwapInt32 atomically stores new into *addr and returns the previous *addr value.
func ( *int32,  int32) ( int32)
SwapInt64 atomically stores new into *addr and returns the previous *addr value.
func ( *int64,  int64) ( int64)
SwapUint32 atomically stores new into *addr and returns the previous *addr value.
func ( *uint32,  uint32) ( uint32)
SwapUint64 atomically stores new into *addr and returns the previous *addr value.
func ( *uint64,  uint64) ( uint64)
SwapUintptr atomically stores new into *addr and returns the previous *addr value.
func ( *uintptr,  uintptr) ( uintptr)
SwapPointer atomically stores new into *addr and returns the previous *addr value.
CompareAndSwapInt32 executes the compare-and-swap operation for an int32 value.
func ( *int32, ,  int32) ( bool)
CompareAndSwapInt64 executes the compare-and-swap operation for an int64 value.
func ( *int64, ,  int64) ( bool)
CompareAndSwapUint32 executes the compare-and-swap operation for a uint32 value.
func ( *uint32, ,  uint32) ( bool)
CompareAndSwapUint64 executes the compare-and-swap operation for a uint64 value.
func ( *uint64, ,  uint64) ( bool)
CompareAndSwapUintptr executes the compare-and-swap operation for a uintptr value.
func ( *uintptr, ,  uintptr) ( bool)
CompareAndSwapPointer executes the compare-and-swap operation for a unsafe.Pointer value.
func ( *unsafe.Pointer, ,  unsafe.Pointer) ( bool)
AddInt32 atomically adds delta to *addr and returns the new value.
func ( *int32,  int32) ( int32)
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 ( *uint32,  uint32) ( uint32)
AddInt64 atomically adds delta to *addr and returns the new value.
func ( *int64,  int64) ( int64)
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 ( *uint64,  uint64) ( uint64)
AddUintptr atomically adds delta to *addr and returns the new value.
func ( *uintptr,  uintptr) ( uintptr)
LoadInt32 atomically loads *addr.
func ( *int32) ( int32)
LoadInt64 atomically loads *addr.
func ( *int64) ( int64)
LoadUint32 atomically loads *addr.
func ( *uint32) ( uint32)
LoadUint64 atomically loads *addr.
func ( *uint64) ( uint64)
LoadUintptr atomically loads *addr.
func ( *uintptr) ( uintptr)
LoadPointer atomically loads *addr.
StoreInt32 atomically stores val into *addr.
func ( *int32,  int32)
StoreInt64 atomically stores val into *addr.
func ( *int64,  int64)
StoreUint32 atomically stores val into *addr.
func ( *uint32,  uint32)
StoreUint64 atomically stores val into *addr.
func ( *uint64,  uint64)
StoreUintptr atomically stores val into *addr.
func ( *uintptr,  uintptr)
StorePointer atomically stores val into *addr.