Documentation
¶
Overview ¶
Package atom provides simple wrappers around types enforcing atomic usage
The wrapper types do not introduce any size overhead and have the same size as the wrapped type.
Index ¶
- type Bool
- type Duration
- func (d *Duration) Add(delta time.Duration) (new time.Duration)
- func (d *Duration) CompareAndSwap(old, new time.Duration) (swapped bool)
- func (d *Duration) Set(value time.Duration)
- func (d *Duration) Sub(delta time.Duration) (new time.Duration)
- func (d *Duration) Swap(new time.Duration) (old time.Duration)
- func (d *Duration) Value() (value time.Duration)
- type Error
- type Float32
- type Float64
- type Int
- type Int32
- type Int64
- type Pointer
- type String
- type Uint
- type Uint32
- type Uint64
- type Uintptr
- type Value
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 is a wrapper around uint32 for usage as a boolean value with atomic access.
func (*Bool) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
type Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration is a wrapper for atomically accessed time.Duration values.
func (*Duration) Add ¶
Add atomically adds delta to the current value and returns the new value. No arithmetic overflow checks are applied.
func (*Duration) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
func (*Duration) Sub ¶
Sub atomically subtracts delta to the current value and returns the new value. No arithmetic underflow checks are applied.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is a wrapper for atomically accessed error values
type Float32 ¶
type Float32 struct {
// contains filtered or unexported fields
}
Float32 is a wrapper for atomically accessed float32 values.
func (*Float32) Add ¶
Add adds delta to the current value and returns the new value. Note: Internally this performs a CompareAndSwap operation within a loop.
func (*Float32) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
func (*Float32) Sub ¶
Sub atomically subtracts delta to the current value and returns the new value.
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 is a wrapper for atomically accessed float64 values.
func (*Float64) Add ¶
Add adds delta to the current value and returns the new value. Note: Internally this performs a CompareAndSwap operation within a loop.
func (*Float64) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
func (*Float64) Sub ¶
Sub atomically subtracts delta to the current value and returns the new value.
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int is a wrapper for atomically accessed int values.
func (*Int) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 is a wrapper for atomically accessed int32 values.
func (*Int32) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 is a wrapper for atomically accessed int64 values.
func (*Int64) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
type Pointer ¶
type Pointer struct {
// contains filtered or unexported fields
}
Pointer is a wrapper for atomically accessed unsafe.Pointer values.
func (*Pointer) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is a wrapper for atomically accessed string values. Note: The string value is wrapped in an interface. Thus, this wrapper has a memory overhead.
type Uint ¶
type Uint struct {
// contains filtered or unexported fields
}
Uint is a wrapper for atomically accessed uint values.
func (*Uint) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 is a wrapper for atomically accessed uint32 values.
func (*Uint32) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
Uint64 is a wrapper for atomically accessed uint64 values.
func (*Uint64) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
type Uintptr ¶
type Uintptr struct {
// contains filtered or unexported fields
}
Uintptr is a wrapper for atomically accessed uintptr values.
func (*Uintptr) CompareAndSwap ¶
CompareAndSwap atomically sets the new value only if the current value matches the given old value and returns whether the new value was set.
func (*Uintptr) Sub ¶
Sub atomically subtracts delta to the current value and returns the new value.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is a wrapper for atomically accessed consistently typed values.