Documentation
¶
Overview ¶
Package workerpool provides a generic worker pool for parallel processing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultWorkers ¶
func DefaultWorkers() int
DefaultWorkers returns the default number of workers based on CPU count.
func ProcessAll ¶
func ProcessAll[In, Out any]( ctx context.Context, items []In, cfg Config, fn func(context.Context, In) (Out, error), ) ([]Out, []error)
ProcessAll runs fn concurrently over items using a pool of workers. It returns results in the same order as input items. The context controls cancellation; if cancelled, partial results are still returned.
Types ¶
type Config ¶
type Config struct {
// Workers is the number of concurrent workers. Zero uses DefaultWorkers().
Workers int
}
Config controls pool behavior.
func (Config) EffectiveWorkers ¶
EffectiveWorkers returns the worker count, using default if not set.
type ItemResult ¶
ItemResult holds the result of processing a single item.
Click to show internal directories.
Click to hide internal directories.