channels

package
v0.426.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IterContext

func IterContext[T any](ctx context.Context, ch <-chan T) iter.Seq[T]

IterContext returns an iterator that iterates over the channel until the channel is closed or the context cancelled.

Check ctx.Err() != nil to detect if the context was cancelled.

Types

type Notifier added in v0.421.0

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

Notifier helps to notify multiple subscribers that an event has occurred.

func NewNotifier added in v0.421.0

func NewNotifier(ctx context.Context) *Notifier

NewNotifier creates a new Notifier instance.

The returned Notifier will automatically close all subscribers when the context is cancelled.

func (*Notifier) Notify added in v0.421.0

func (b *Notifier) Notify(ctx context.Context)

Notify all subscribers.

func (*Notifier) Subscribe added in v0.421.0

func (b *Notifier) Subscribe() <-chan struct{}

Subscribe to the notifier.

The returned channel will be closed when the notifier context is cancelled.

Jump to

Keyboard shortcuts

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