atomic

package
v0.0.0-...-d7985ca Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lazy

type Lazy[T any] struct {
	Resolve func(context.Context) (T, error)
	// contains filtered or unexported fields
}

Lazy persistently stores a value in memory by evaluating the Resolve function when the value is accessed

func (*Lazy[T]) Set

func (c *Lazy[T]) Set(v T)

Set assigns the passed value

func (*Lazy[T]) TryGet

func (c *Lazy[T]) TryGet(ctx context.Context, opts ...functional.Option[Options]) (T, error)

TryGet attempts to get a non-nil value from the internal value. If the internal value is nil, the Resolve function will attempt to resolve the value, setting the value to be persistently stored if the resolve of Resolve is non-nil.

type Options

type Options struct {
	// contains filtered or unexported fields
}

func IgnoreCacheOption

func IgnoreCacheOption(o Options) Options

type Slice

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

Slice exposes a slice of a type in a race-free manner.

func (*Slice[T]) Add

func (a *Slice[T]) Add(input T)

func (*Slice[T]) Len

func (a *Slice[T]) Len() int

func (*Slice[T]) Range

func (a *Slice[T]) Range(f func(pool T) bool)

func (*Slice[T]) Reset

func (a *Slice[T]) Reset()

func (*Slice[T]) Set

func (a *Slice[T]) Set(values []T)

Jump to

Keyboard shortcuts

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