valuenotifier

package
v0.0.0-...-c635e59 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrListenerDeregistered = ierrors.New("listener was deregistered")
)

Functions

This section is empty.

Types

type Listener

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

func (*Listener) Deregister

func (l *Listener) Deregister()

Deregister the listener to clean up memory in case it was not de-registered yet.

func (*Listener) Wait

func (l *Listener) Wait(ctx context.Context) error

Wait waits until the listener is notified or the context is done. If the context was done, the listener de-registers automatically to clean up memory.

type Notifier

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

func New

func New[T comparable]() *Notifier[T]

func (*Notifier[T]) Listener

func (v *Notifier[T]) Listener(value T) *Listener

Listener creates a unique listener that can be used to wait until Notify is called for the given value.

func (*Notifier[T]) Notify

func (v *Notifier[T]) Notify(value T)

Jump to

Keyboard shortcuts

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