Documentation ¶
Overview ¶
Package atomic contains type-safe atomic types.
The zero value for the numeric types cannot be used. Use New*. The rationale for this behaviour is that copying an atomic integer is not reliable. Copying can be prevented by embedding sync.Mutex, but that bloats the type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Int ¶
type Int[T atomicint] interface { Interface[T] // Add a value and return the new result. Add(delta T) (new T) }
Int expresses atomic operations on signed or unsigned integer values.
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 atomic value.
Copying creates an alias. The zero value is not usable, use NewInt32.
func (Int32) CompareAndSwap ¶
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 atomic value.
Copying creates an alias.
func (Int64) CompareAndSwap ¶
type Interface ¶
type Interface[T any] interface { // Load value atomically. Load() T // Store value atomically. Store(value T) // Swap the previous value with the new value atomically. Swap(new T) (old T) // CompareAndSwap the previous value with new if its value is "old". CompareAndSwap(old, new T) (swapped bool) }
Interface represents atomic operations on a value.
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 atomic value.
Copying creates an alias.
func (Uint32) CompareAndSwap ¶
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
Uint64 atomic value.
Copying creates an alias.
func (Uint64) CompareAndSwap ¶
type Value ¶
type Value[T any] struct { // contains filtered or unexported fields }
Value wraps any generic value in atomic load and store operations.