Documentation
¶
Overview ¶
Package atomics implements efficient atomic types.
Index ¶
- type Bool
- type Float32
- func (v *Float32) Add(delta float32) (new float32)
- func (v *Float32) CompareAndSwap(old, new float32) (swapped bool)
- func (v *Float32) Decrement() (new float32)
- func (v *Float32) Increment() (new float32)
- func (v *Float32) Load() (val float32)
- func (v *Float32) Raw() *uint32
- func (v *Float32) Reset() (old float32)
- func (v *Float32) Store(val float32)
- func (v *Float32) String() string
- func (v *Float32) Subtract(delta float32) (new float32)
- func (v *Float32) Swap(new float32) (old float32)
- type Float64
- func (v *Float64) Add(delta float64) (new float64)
- func (v *Float64) CompareAndSwap(old, new float64) (swapped bool)
- func (v *Float64) Decrement() (new float64)
- func (v *Float64) Increment() (new float64)
- func (v *Float64) Load() (val float64)
- func (v *Float64) Raw() *uint64
- func (v *Float64) Reset() (old float64)
- func (v *Float64) Store(val float64)
- func (v *Float64) String() string
- func (v *Float64) Subtract(delta float64) (new float64)
- func (v *Float64) Swap(new float64) (old float64)
- type Int32
- func (v *Int32) Add(delta int32) (new int32)
- func (v *Int32) CompareAndSwap(old, new int32) (swapped bool)
- func (v *Int32) Decrement() (new int32)
- func (v *Int32) Increment() (new int32)
- func (v *Int32) Load() (val int32)
- func (v *Int32) Raw() *int32
- func (v *Int32) Reset() (old int32)
- func (v *Int32) Store(val int32)
- func (v *Int32) String() string
- func (v *Int32) Subtract(delta int32) (new int32)
- func (v *Int32) Swap(new int32) (old int32)
- type Int64
- func (v *Int64) Add(delta int64) (new int64)
- func (v *Int64) CompareAndSwap(old, new int64) (swapped bool)
- func (v *Int64) Decrement() (new int64)
- func (v *Int64) Increment() (new int64)
- func (v *Int64) Load() (val int64)
- func (v *Int64) Raw() *int64
- func (v *Int64) Reset() (old int64)
- func (v *Int64) Store(val int64)
- func (v *Int64) String() string
- func (v *Int64) Subtract(delta int64) (new int64)
- func (v *Int64) Swap(new int64) (old int64)
- type String
- type Uint32
- func (v *Uint32) Add(delta uint32) (new uint32)
- func (v *Uint32) CompareAndSwap(old, new uint32) (swapped bool)
- func (v *Uint32) Decrement() (new uint32)
- func (v *Uint32) Increment() (new uint32)
- func (v *Uint32) Load() (val uint32)
- func (v *Uint32) Raw() *uint32
- func (v *Uint32) Reset() (old uint32)
- func (v *Uint32) Store(val uint32)
- func (v *Uint32) String() string
- func (v *Uint32) Subtract(delta uint32) (new uint32)
- func (v *Uint32) Swap(new uint32) (old uint32)
- type Uint64
- func (v *Uint64) Add(delta uint64) (new uint64)
- func (v *Uint64) CompareAndSwap(old, new uint64) (swapped bool)
- func (v *Uint64) Decrement() (new uint64)
- func (v *Uint64) Increment() (new uint64)
- func (v *Uint64) Load() (val uint64)
- func (v *Uint64) Raw() *uint64
- func (v *Uint64) Reset() (old uint64)
- func (v *Uint64) Store(val uint64)
- func (v *Uint64) String() string
- func (v *Uint64) Subtract(delta uint64) (new uint64)
- func (v *Uint64) Swap(new uint64) (old uint64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool provides an atomic bool.
func (*Bool) CompareAndSwap ¶
CompareAndSwap sets the value of the bool to new but only if it currently has the value old. It returns true if the swap succeeded.
func (*Bool) Raw ¶
Raw returns a pointer to the underlying uint32.
It is only safe to access the pointer with methods from the sync/atomic package. Use caution if manually dereferencing.
The true value is stored as one, false is stored as zero.
The behaviour of Bool is undefined if this value is set to anything other than zero or one.
type Float32 ¶
type Float32 struct {
// contains filtered or unexported fields
}
Float32 provides an atomic float32.
func NewFloat32 ¶
NewFloat32 returns an atomic float32 with a given value.
func (*Float32) CompareAndSwap ¶
CompareAndSwap sets the value of the float32 to new but only if it currently has the value old. It returns true if the swap succeeded.
func (*Float32) Raw ¶
Raw returns a pointer to the float32.
It is only safe to access the pointer with methods from the sync/atomic package. Use caution if manually dereferencing.
This returns the underlying uint32, to convert this to and from a float32, use math.Float32frombits and math.Float32bits respectively.
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 provides an atomic float64.
func NewFloat64 ¶
NewFloat64 returns an atomic float64 with a given value.
func (*Float64) CompareAndSwap ¶
CompareAndSwap sets the value of the float64 to new but only if it currently has the value old. It returns true if the swap succeeded.
func (*Float64) Raw ¶
Raw returns a pointer to the float64.
It is only safe to access the pointer with methods from the sync/atomic package. Use caution if manually dereferencing.
This returns the underlying uint64, to convert this to and from a float64, use math.Float64frombits and math.Float64bits respectively.
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 provides an atomic int32.
func (*Int32) CompareAndSwap ¶
CompareAndSwap sets the value of the int32 to new but only if it currently has the value old. It returns true if the swap succeeded.
func (*Int32) Raw ¶
Raw returns a pointer to the int32.
It is only safe to access the pointer with methods from the sync/atomic package. Use caution if manually dereferencing.
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 provides an atomic int64.
func (*Int64) CompareAndSwap ¶
CompareAndSwap sets the value of the int64 to new but only if it currently has the value old. It returns true if the swap succeeded.
func (*Int64) Raw ¶
Raw returns a pointer to the int64.
It is only safe to access the pointer with methods from the sync/atomic package. Use caution if manually dereferencing.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String provides an atomic string.
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 provides an atomic uint32.
func (*Uint32) CompareAndSwap ¶
CompareAndSwap sets the value of the uint32 to new but only if it currently has the value old. It returns true if the swap succeeded.
func (*Uint32) Raw ¶
Raw returns a pointer to the uint32.
It is only safe to access the pointer with methods from the sync/atomic package. Use caution if manually dereferencing.
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
Uint64 provides an atomic uint64.
func (*Uint64) CompareAndSwap ¶
CompareAndSwap sets the value of the uint64 to new but only if it currently has the value old. It returns true if the swap succeeded.
func (*Uint64) Raw ¶
Raw returns a pointer to the uint64.
It is only safe to access the pointer with methods from the sync/atomic package. Use caution if manually dereferencing.