tracker

package
v0.15.20 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

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