progress

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 3 Imported by: 0 modules, 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

Overview

Package progress tells the window how far a long read has got while it runs: the phase under way and how many of the phase's things are done, as an event the caller builds, at most a few times a second. The Release page's list and the worktrees' listing tell theirs through it.

Index

Constants

View Source
const Every = 250 * time.Millisecond

Every is how often, at most, a Tracker tells the window: four times a second.

Variables

This section is empty.

Functions

This section is empty.

Types

type Build

type Build[P ~string] func(phase P, done, total int) event.Event

Build makes the event that tells the window phase, with done of total counted off.

type Tracker

type Tracker[P ~string] struct {
	// contains filtered or unexported fields
}

Tracker tells how far one read has got, as the event its Build makes of the phase under way and its counts. It tells at most once per every; a change that comes sooner waits out the rest of that time, and the changes that come meanwhile go with it, so the window always ends up with the latest counts. Once the read ends, it tells nothing more. A nil Tracker tells nothing, so a read nobody watches passes none. It is safe for concurrent use.

func New

func New[P ~string](events event.Sink, every time.Duration, build Build[P]) *Tracker[P]

New returns the Tracker of a read that tells events at most once per every.

func (*Tracker[P]) Add

func (t *Tracker[P]) Add(n int)

Add counts n more of the phase's total done, never past the total. Any goroutine may call it.

func (*Tracker[P]) End

func (t *Tracker[P]) End()

End stops telling: the read landed, failed, or was cut short.

func (*Tracker[P]) Start

func (t *Tracker[P]) Start(phase P, total int)

Start begins phase, with total things to count off; 0 counts nothing.

Jump to

Keyboard shortcuts

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