tracker

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tracker

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

Tracker is a replacement for sync.WaitGroup that properly handles the case when a goroutine attempts to call Add after Wait has been called. For example:

Goroutine A (server shutdown) wg.Wait() // waits for all work to finish

Goroutine B (handling request) - might run AFTER Wait() starts wg.Add(1) // PANIC or undefined behaviour

With Tracker, Add returns false instead and Goroutine B can handle the rejection gracefully.

Inspired by net/http See https://cs.opensource.google/go/go/+/refs/tags/go1.25.1:src/net/http/server.go;l=3604

func (*Tracker) Add

func (g *Tracker) Add(delta int) bool

func (*Tracker) Done

func (g *Tracker) Done()

func (*Tracker) Wait

func (g *Tracker) Wait()

Jump to

Keyboard shortcuts

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