Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NMap ¶
func NMap(n int, fn func(m int) (r any, err error), options ...Option) (resultlist []any, errorlist []error)
NMap works on every integer in the range from 0 to ... n-1 in parallel The function works with 2 arguments and an (optional) option
- an integer n
- a worker function with one argument (an integer) which produces a result (type any) and an error
The (optional) option gives a maximum of go-routines doing work.
The function return 2 values:
- resultlist: a slice of any (the result of each individual worker)
- errorlist: a slice of error (the error of each individual worker)
Options:
WithMax(int): maximum workers (the default is lower than runtime.GOMAXPROCS(-1))
Example:
resultlist, errorlist := parallel.NMap(100, func(m int) {....} (any, err), parallel.WithMax(7))
Types ¶
Click to show internal directories.
Click to hide internal directories.