Documentation
¶
Overview ¶
Package parallel provides useful convenience helpers for parallel / batch execution
Index ¶
- func ExecuteChunkAsync[I any, O any](tasks []I, chunkSize int, f func(chunk []I) ([]O, error), workerCount int) ([]O, error)
- func ExecuteChunkSync[I any, O any](tasks []I, chunkSize int, f func(chunk []I) ([]O, error)) ([]O, error)
- func ExecutePool[I any, O any](tasks []I, f func(task I) O, workerCount int) []O
- func ExecutePool2[I any, O any](tasks []I, f func(task I) (O, error), workerCount int) ([]O, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteChunkAsync ¶ added in v1.0.1
func ExecuteChunkAsync[I any, O any]( tasks []I, chunkSize int, f func(chunk []I) ([]O, error), workerCount int, ) ([]O, error)
ExecuteChunkAsync executes provided data in chunks with pool workers.
func ExecuteChunkSync ¶ added in v1.0.1
func ExecuteChunkSync[I any, O any]( tasks []I, chunkSize int, f func(chunk []I) ([]O, error), ) ([]O, error)
ExecuteChunkSync executes provided function over tasks in chunks synchronously.
func ExecutePool ¶ added in v1.0.1
ExecutePool is a convenience helper that distributes input tasks into workerCount workers then collects the result.
Output values are not expected to have the same order as they came in.
Panics when provided executor panics.
func ExecutePool2 ¶ added in v1.0.1
func ExecutePool2[I any, O any]( tasks []I, f func(task I) (O, error), workerCount int, ) ([]O, error)
ExecutePool2 is a convenience helper that distributes input tasks into workerCount runners then collects the result.
Output values are not expected to have the same order as they came in.
Fails when either of workers fails with nil res and error, otherwise error is nil and the result is OK.
Types ¶
This section is empty.