Help us shape the future of Go! Take the 2026 Go Developer Survey

ccontainer

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CContainer

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

CContainer is a concurrent container.

func NewCContainer

func NewCContainer[T comparable](val T) *CContainer[T]

NewCContainer builds a CContainer with an initial value.

func (*CContainer[T]) GetValue added in v0.16.2

func (c *CContainer[T]) GetValue() T

GetValue returns the immediate value of the container.

func (*CContainer[T]) SetValue

func (c *CContainer[T]) SetValue(val T)

SetValue sets the ccontainer value.

func (*CContainer[T]) SwapValue added in v0.18.2

func (c *CContainer[T]) SwapValue(cb func(val T) T) T

SwapValue locks the container, calls the callback, and stores the return value.

Returns the updated value.

func (*CContainer[T]) WaitValue

func (c *CContainer[T]) WaitValue(ctx context.Context, errCh <-chan error) (T, error)

WaitValue waits for any non-nil value in the container. errCh is an optional channel to read an error from.

func (*CContainer[T]) WaitValueChange

func (c *CContainer[T]) WaitValueChange(ctx context.Context, old T, errCh <-chan error) (T, error)

WaitValueChange waits for a value that is different than the given. errCh is an optional channel to read an error from.

func (*CContainer[T]) WaitValueEmpty

func (c *CContainer[T]) WaitValueEmpty(ctx context.Context, errCh <-chan error) error

WaitValueEmpty waits for an empty value. errCh is an optional channel to read an error from.

func (*CContainer[T]) WaitValueWithValidator

func (c *CContainer[T]) WaitValueWithValidator(
	ctx context.Context,
	valid func(v T) (bool, error),
	errCh <-chan error,
) (T, error)

WaitValueWithValidator waits for any value that matches the validator in the container. errCh is an optional channel to read an error from.

Jump to

Keyboard shortcuts

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