wave

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package wave computes parallel execution waves from a dependency graph of ticks using Kahn's algorithm (topological sort by levels).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Waves    []Wave
	CycleIDs []string // non-empty when a circular dependency is detected
}

Result holds the computed waves and any cycle information.

func Compute

func Compute(tasks []*tick.Tick, allTicks ...[]tick.Tick) Result

Compute returns the waves for a set of tasks using Kahn's algorithm. Only includes tasks that are open (not closed) and not awaiting human action. Tasks are grouped into waves based on their BlockedBy dependencies. Within each wave, tasks are sorted by priority (ascending), then by ID.

If allTicks is provided, it is used to look up the status of blockers that are outside the task set (mirroring query.Ready semantics): an open external blocker keeps its dependents out of wave 1 — it acts as a virtual wave-1 node, so dependents land in wave 2 or later. Missing blockers are treated as closed (handles orphaned references). Without allTicks, blockers outside the task set are ignored entirely (legacy behavior).

Note that wave 1 may be absent when no task is unblocked: wave numbers reflect rounds-until-ready, so the first emitted wave can be Number 2.

func (Result) MaxWidth

func (r Result) MaxWidth() int

MaxWidth returns the maximum number of tasks in any single wave, i.e. the peak parallelism. Returns 0 if there are no waves.

type Wave

type Wave struct {
	Number int
	Tasks  []*tick.Tick
}

Wave represents a group of tasks that can execute in parallel.

Jump to

Keyboard shortcuts

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