Documentation ¶
Overview ¶
Package atomic provides simple wrappers around numerics to enforce atomic access.
Example ¶
package main import ( "fmt" "go.uber.org/atomic" ) func main() { // Uint32 is a thin wrapper around the primitive uint32 type. var atom atomic.Uint32 // The wrapper ensures that all operations are atomic. atom.Store(42) fmt.Println(atom.Inc()) fmt.Println(atom.CAS(43, 0)) fmt.Println(atom.Load()) }
Output: 43 true 0
Index ¶
Examples ¶
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 an atomic Boolean.
type Duration ¶ added in v1.3.2
type Duration struct {
// contains filtered or unexported fields
}
Duration is an atomic wrapper around time.Duration https://godoc.org/time#Duration
func NewDuration ¶ added in v1.3.2
NewDuration creates a Duration.
func (*Duration) Add ¶ added in v1.3.2
Add atomically adds to the wrapped time.Duration and returns the new value.
type Error ¶ added in v1.4.0
type Error struct {
// contains filtered or unexported fields
}
Error is an atomic type-safe wrapper around Value for errors
type Float64 ¶ added in v1.1.0
type Float64 struct {
// contains filtered or unexported fields
}
Float64 is an atomic wrapper around float64.
func (*Float64) Add ¶ added in v1.1.0
Add atomically adds to the wrapped float64 and returns the new value.
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 is an atomic wrapper around an int32.
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 is an atomic wrapper around an int64.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is an atomic type-safe wrapper around Value for strings.
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 is an atomic wrapper around an uint32.
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
Uint64 is an atomic wrapper around a uint64.
type Value ¶ added in v1.2.0
Value shadows the type of the same name from sync/atomic https://godoc.org/sync/atomic#Value