MCPcopy Create free account
hub / github.com/sourcegraph/conc / ForEach

Function ForEach

iter/iter.go:36–36  ·  view source on GitHub ↗

ForEach executes f in parallel over each element in input. It is safe to mutate the input parameter, which makes it possible to map in place. ForEach always uses at most runtime.GOMAXPROCS goroutines. It takes roughly 2µs to start up the goroutines and adds an overhead of roughly 50ns per element

(input []T, f func(*T))

Source from the content-addressed store, hash-verified

34// an overhead of roughly 50ns per element of input. For
35// a configurable goroutine limit, use a custom Iterator.
36func ForEach[T any](input []T, f func(*T)) { Iterator[T]{}.ForEach(input, f) }
37
38// ForEach executes f in parallel over each element in input,
39// using up to the Iterator's configured maximum number of

Callers 2

TestForEachFunction · 0.85
BenchmarkForEachFunction · 0.85

Calls 1

ForEachMethod · 0.80

Tested by 2

TestForEachFunction · 0.68
BenchmarkForEachFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…