concurrency

package
v0.0.0-...-bd61e48 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LastChan

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

func NewLastChan

func NewLastChan() *LastChan

func (*LastChan) Close

func (lc *LastChan) Close()

func (*LastChan) Load

func (lc *LastChan) Load() int64

func (*LastChan) Update

func (lc *LastChan) Update(val int64)

func (*LastChan) Wait

func (lc *LastChan) Wait() <-chan struct{}

type Latch

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

Latch is a thread-safe value holder that can be set once and read many times. Once Set is called, all future Wait calls will immediately return the set value.

func NewLatch

func NewLatch[T any]() *Latch[T]

NewLatch creates a new Latch for type T.

func (*Latch[T]) Chan

func (l *Latch[T]) Chan() <-chan struct{}

Chan returns a channel that will be closed when the value is set. Useful for select statements.

func (*Latch[T]) IsSet

func (l *Latch[T]) IsSet() bool

IsSet returns true if the value has been set.

func (*Latch[T]) Set

func (l *Latch[T]) Set(v T)

Set publishes the value exactly once; later calls are no-ops.

func (*Latch[T]) Wait

func (l *Latch[T]) Wait() T

Wait blocks until Set is called, then returns the value. Safe to call many times; subsequent calls return immediately.

Jump to

Keyboard shortcuts

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