counter

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 0 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoRoutineCounter

type GoRoutineCounter interface {
	// Add adds the given delta to the count of active goroutines.
	// Call Add(1) before forking a goroutine, Add(-1) at the end of that goroutine.
	// Call Add(-1) just before waiting on something from another goroutine (e.g.,
	// just before a `select`).
	// Call Add(1) just before doing something that unblocks a goroutine that is
	// waiting on that something.
	Add(delta int)
}

GoRoutineCounter keeps track of the number of active goroutines working on/for something. This is a utility that makes such code more testable. The code uses this utility to report the number of active goroutines to the test code, so that the test code can advance a fake clock when and only when the code being tested has finished all the work that is ready to do at the present time.

type NoOp added in v0.18.0

type NoOp struct{}

NoOp is a GoRoutineCounter that does not actually count

func (NoOp) Add added in v0.18.0

func (NoOp) Add(int)

Add would adjust the count, if a count were being kept

Jump to

Keyboard shortcuts

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