waker

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTest

func NewTest(ctx context.Context, n int) (Waker, WakeFunc)

NewTest creates a new Waker to be used in tests, returning it and a function to trigger a wakeup. The constructor parameter says how many wakees are expected in the first pass.

Types

type WakeFunc

type WakeFunc func(int)

WakeFunc describes a function used by tests to trigger a wakeup of blocked idle goroutines under test. It takes as first parameter the number of goroutines to await before returning to the caller.

type Waker

type Waker interface {
	// Wake returns a channel that's closed when the idle routine should wake up.
	Wake() <-chan struct{}
}

A Waker is used to signal to idle routines it's time to look for new work.

func NewTestAlways

func NewTestAlways() Waker

func NewTimed

func NewTimed(ctx context.Context, interval time.Duration) Waker

NewTimed returns a new timedWaker that is shut down when the context is cancelled.

Jump to

Keyboard shortcuts

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