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
- func (i *Int32) Add(v int32) int32
- func (i *Int32) CompareAndSwap(oldVal, newVal int32) bool
- func (i *Int32) Load() int32
- func (i *Int32) RacyAdd(v int32) int32
- func (i *Int32) RacyLoad() int32
- func (i *Int32) RacyStore(v int32)
- func (i *Int32) StateFields() []string
- func (i *Int32) StateLoad(stateSourceObject state.Source)
- func (i *Int32) StateSave(stateSinkObject state.Sink)
- func (i *Int32) StateTypeName() string
- func (i *Int32) Store(v int32)
- func (i *Int32) Swap(v int32) int32
- type Int64
- func (i *Int64) Add(v int64) int64
- func (i *Int64) CompareAndSwap(oldVal, newVal int64) bool
- func (i *Int64) Load() int64
- func (i *Int64) RacyAdd(v int64) int64
- func (i *Int64) RacyLoad() int64
- func (i *Int64) RacyStore(v int64)
- func (i *Int64) StateFields() []string
- func (i *Int64) StateLoad(stateSourceObject state.Source)
- func (i *Int64) StateSave(stateSinkObject state.Sink)
- func (i *Int64) StateTypeName() string
- func (i *Int64) Store(v int64)
- func (i *Int64) Swap(v int64) 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) StateFields() []string
- func (u *Uint32) StateLoad(stateSourceObject state.Source)
- func (u *Uint32) StateSave(stateSinkObject state.Sink)
- func (u *Uint32) StateTypeName() string
- 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) StateFields() []string
- func (u *Uint64) StateLoad(stateSourceObject state.Source)
- func (u *Uint64) StateSave(stateSinkObject state.Sink)
- func (u *Uint64) StateTypeName() string
- 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
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.
func (*Int32) RacyStore ¶
RacyStore is analogous to setting an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
Don't add fields to this struct. It is important that it remain the same size as its builtin analogue.
func (*Int32) StateFields ¶
func (*Int32) StateTypeName ¶
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.
func (*Int64) RacyStore ¶
RacyStore is analogous to setting an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
func (*Int64) StateFields ¶
func (*Int64) StateTypeName ¶
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 is an atomic uint32.
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.
func (*Uint32) RacyStore ¶
RacyStore is analogous to setting an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.
func (*Uint32) StateFields ¶
func (*Uint32) StateTypeName ¶
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.
func (*Uint64) RacyStore ¶
RacyStore is analogous to setting an atomic value without using synchronization.
It may be helpful to document why a racy operation is permitted.