Documentation ¶
Overview ¶
Package atomicbitops provides extensions to the sync/atomic package.
All read-modify-write operations implemented by this package have acquire-release memory ordering (like sync/atomic).
+checkalignedignore
Index ¶
- func AndUint32(addr *Uint32, val uint32)
- func AndUint64(addr *Uint64, val uint64)
- func CompareAndSwapUint32(addr *Uint32, old, new uint32) uint32
- func CompareAndSwapUint64(addr *Uint64, old, new uint64) uint64
- func OrUint32(addr *Uint32, val uint32)
- func OrUint64(addr *Uint64, val uint64)
- func XorUint32(addr *Uint32, val uint32)
- func XorUint64(addr *Uint64, val uint64)
- type Bool
- type Float64
- type Int32
- type Int64
- type Uint32
- func (u *Uint32) Add(v uint32) uint32
- func (u *Uint32) CompareAndSwap(oldVal, newVal uint32) bool
- func (u *Uint32) Load() uint32
- func (u *Uint32) RacyAdd(v uint32) uint32
- func (u *Uint32) RacyLoad() uint32
- func (u *Uint32) RacyStore(v uint32)
- func (u *Uint32) Store(v uint32)
- func (u *Uint32) Swap(v uint32) uint32
- type Uint64
- func (u *Uint64) Add(v uint64) uint64
- func (u *Uint64) CompareAndSwap(oldVal, newVal uint64) bool
- func (u *Uint64) Load() uint64
- func (u *Uint64) RacyAdd(v uint64) uint64
- func (u *Uint64) RacyLoad() uint64
- func (u *Uint64) RacyStore(v uint64)
- func (u *Uint64) Store(v uint64)
- func (u *Uint64) Swap(v uint64) uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareAndSwapUint32 ¶
CompareAndSwapUint32 is like sync/atomic.CompareAndSwapUint32, but returns the value previously stored at addr.
func CompareAndSwapUint64 ¶
CompareAndSwapUint64 is like sync/atomic.CompareAndSwapUint64, but returns the value previously stored at addr.
Types ¶
type Bool ¶
type Bool struct {
Uint32
}
Bool is an atomic Boolean.
It is implemented by a Uint32, with value 0 indicating false, and 1 indicating true.
+stateify savable
func (*Bool) CompareAndSwap ¶
CompareAndSwap is analogous to atomic.CompareAndSwapBool, if such a thing existed.
func (*Bool) RacyLoad ¶
RacyLoad is analogous to reading an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
func (*Bool) RacyStore ¶
RacyStore is analogous to setting an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 is an atomic 64-bit floating-point number.
+stateify savable
func FromFloat64 ¶
FromFloat64 returns a Float64 initialized to value v.
func (*Float64) Add ¶
Add increments the float by the given value. Note that unlike an atomic integer, this requires spin-looping until we win the compare-and-swap race, so this may take an indeterminate amount of time.
func (*Float64) CompareAndSwap ¶
CompareAndSwap does a compare-and-swap operation on the float64 value. Note that unlike typical IEEE 754 semantics, this function will treat NaN as equal to itself if all of its bits exactly match.
func (*Float64) RacyLoad ¶
RacyLoad is analogous to reading an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
func (*Float64) RacyStore ¶
RacyStore is analogous to setting an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 is an atomic int32.
The default value is zero.
Don't add fields to this struct. It is important that it remain the same size as its builtin analogue.
+stateify savable
func (*Int32) CompareAndSwap ¶
CompareAndSwap is analogous to atomic.CompareAndSwapInt32.
func (*Int32) RacyAdd ¶
RacyAdd is analogous to adding to an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
func (*Int32) RacyLoad ¶
RacyLoad is analogous to reading an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 is an atomic int64 that is guaranteed to be 64-bit aligned, even on 32-bit systems. On most architectures, it's just a regular int64.
The default value is zero.
Don't add fields to this struct. It is important that it remain the same size as its builtin analogue.
See aligned_32bit_unsafe.go in this directory for justification.
+stateify savable
func (*Int64) CompareAndSwap ¶
CompareAndSwap is analogous to atomic.CompareAndSwapInt64.
func (*Int64) RacyAdd ¶
RacyAdd is analogous to adding to an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
func (*Int64) RacyLoad ¶
RacyLoad is analogous to reading an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 is an atomic uint32.
Don't add fields to this struct. It is important that it remain the same size as its builtin analogue.
See aligned_unsafe.go in this directory for justification.
+stateify savable
func FromUint32 ¶
FromUint32 returns an Uint32 initialized to value v.
func (*Uint32) CompareAndSwap ¶
CompareAndSwap is analogous to atomic.CompareAndSwapUint32.
func (*Uint32) RacyAdd ¶
RacyAdd is analogous to adding to an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
func (*Uint32) RacyLoad ¶
RacyLoad is analogous to reading an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
Uint64 is an atomic uint64 that is guaranteed to be 64-bit aligned, even on 32-bit systems. On most architectures, it's just a regular uint64.
Don't add fields to this struct. It is important that it remain the same size as its builtin analogue.
See aligned_unsafe.go in this directory for justification.
+stateify savable
func FromUint64 ¶
FromUint64 returns an Uint64 initialized to value v.
func (*Uint64) CompareAndSwap ¶
CompareAndSwap is analogous to atomic.CompareAndSwapUint64.
func (*Uint64) RacyAdd ¶
RacyAdd is analogous to adding to an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
func (*Uint64) RacyLoad ¶
RacyLoad is analogous to reading an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.