atomic

package
v0.0.0-...-726143d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool = atomic.Bool

func NewBool

func NewBool(val bool) *Bool

type Duration

type Duration = atomic.Duration

func NewDuration

func NewDuration(val time.Duration) *Duration

type Error

type Error = atomic.Error

func NewError

func NewError(val error) *Error

type Float64

type Float64 = atomic.Float64

func NewFloat64

func NewFloat64(val float64) *Float64

type Int32

type Int32 = atomic.Int32

func NewInt32

func NewInt32(val int32) *Int32

type Int64

type Int64 = atomic.Int64

func NewInt64

func NewInt64(val int64) *Int64

type Ptr

type Ptr[T any] struct {
	// contains filtered or unexported fields
}

func NewPtr

func NewPtr[T any](val *T) *Ptr[T]

NewPtr creates a new Ptr[T].

func (*Ptr[T]) CompareAndSwap

func (p *Ptr[T]) CompareAndSwap(old, new *T) (swapped bool)

CompareAndSwap executes the compare-and-swap operation for the wrapped pointer.

func (*Ptr[T]) Load

func (p *Ptr[T]) Load() *T

Load atomically loads the wrapped pointer.

func (*Ptr[T]) Store

func (p *Ptr[T]) Store(val *T)

Store atomically stores the passed pointer.

func (*Ptr[T]) Swap

func (p *Ptr[T]) Swap(val *T) (old *T)

Swap atomically swaps the wrapped pointer and returns the old value.

type String

type String = atomic.String

func NewString

func NewString(val string) *String

type Time

type Time = atomic.Time

func NewTime

func NewTime(val time.Time) *Time

type Uint32

type Uint32 = atomic.Uint32

func NewUint32

func NewUint32(val uint32) *Uint32

type Uint64

type Uint64 = atomic.Uint64

func NewUint64

func NewUint64(val uint64) *Uint64

type Uintptr

type Uintptr = atomic.Uintptr

func NewUintptr

func NewUintptr(val uintptr) *Uintptr

type UnsafePointer

type UnsafePointer = atomic.UnsafePointer

func NewUnsafePointer

func NewUnsafePointer(val unsafe.Pointer) *UnsafePointer

type Value

type Value[T comparable] struct {
	// contains filtered or unexported fields
}

Value wrapped a copiable value atomically WARNING: Store, Swap, and CompareAndSwap operations do allocate

func NewValue

func NewValue[T comparable](val T) *Value[T]

NewValue creates a new Value[T].

func (*Value[T]) CompareAndSwap

func (v *Value[T]) CompareAndSwap(old, new T) (swapped bool)

CompareAndSwap executes the compare-and-swap operation for the wrapped pointer.

func (*Value[T]) Load

func (v *Value[T]) Load() T

Load atomically loads the wrapped value.

func (*Value[T]) Store

func (v *Value[T]) Store(val T)

Store atomically stores the passed value.

func (*Value[T]) Swap

func (v *Value[T]) Swap(val T) (old T)

Swap atomically swaps the wrapped pointer and returns the old value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL