Documentation
¶
Overview ¶
Package parallel runs a per-input function under a bounded worker pool and returns results in the original input order. Used by sync, outdated, and sbom to fan out per-package work (recipe fetch, install, version probe) instead of serialising the inner loop.
Semantics:
- Results are returned at the same index as their input.
- Errors are positional, not aggregated — caller decides what counts as fatal.
- One worker failing does NOT cancel peers. Callers that want short-circuit behaviour cancel the supplied context.
- In-flight workers are not killed; they receive the cancelled context via their fn argument.
- maxWorkers <= 0 is normalised to 1.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Limiter ¶ added in v0.16.4
type Limiter struct {
// contains filtered or unexported fields
}
Limiter bounds the number of concurrent holders. Acquire blocks until a slot is free; Release frees one. A nil *Limiter is an unbounded no-op, so call sites can opt out without nil checks.
func NewLimiter ¶ added in v0.16.4
NewLimiter returns a limiter that allows at most n concurrent holders. If n < 1 the limiter is unbounded: Acquire and Release are no-ops.
func (*Limiter) Acquire ¶ added in v0.16.4
func (l *Limiter) Acquire()
Acquire takes a slot, blocking until one is available. A nil limiter or an unbounded limiter returns immediately.