workers

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count() int

Count returns the default bounded worker count for build work.

func IOLimit

func IOLimit(workItems int) int

IOLimit returns a concurrency cap for I/O-bound file operations. SSD-backed filesystems benefit from more outstanding requests than there are CPU cores.

func Limit

func Limit(workItems int) int

Limit returns Count capped to the amount of available work.

func ParallelFor added in v1.0.0

func ParallelFor[T any](items []T, parallel bool, workerCount int, fn func(i int, item T) error) error

ParallelFor runs fn over every item, fanning out to workers when the work justifies it (per ShouldParallelize) and running serially otherwise. The serial path stops at the first error; the parallel path waits for started goroutines and returns the first error. workerCount caps parallel fan-out; when it is <= 0 the cap defaults to Limit(len(items)).

func ShouldParallelize

func ShouldParallelize(enabled bool, workItems, workerCount int) bool

ShouldParallelize reports whether a build phase has enough work to benefit from worker fan-out. Small phases stay serial to avoid goroutine overhead.

Types

This section is empty.

Jump to

Keyboard shortcuts

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