locker

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: BSD-3-Clause Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNested = errors.New("nested locker call")

Functions

This section is empty.

Types

type Locked

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

func New

func New[T any](initial T) *Locked[T]

New creates a new locker for the given value.

func (*Locked[T]) Copy

func (s *Locked[T]) Copy(ctx context.Context) (T, error)

Copy will return a shallow copy of the locked object.

func (*Locked[T]) Use

func (s *Locked[T]) Use(ctx context.Context, fn func(context.Context, T) error) error

Use will call the function with the locked value

Jump to

Keyboard shortcuts

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