mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
arrays.parallel: fix v doc -unsafe-run-examples -f none vlib/arrays/parallel/
too
This commit is contained in:
parent
c96f0b63f2
commit
9771491c94
1 changed files with 2 additions and 2 deletions
|
@ -22,7 +22,7 @@ fn limited_workers(max_workers int, ilen int) int {
|
||||||
// run lets the user run an array of input with a user provided function in parallel.
|
// run lets the user run an array of input with a user provided function in parallel.
|
||||||
// It limits the number of worker threads to min(num_workers, num_cpu).
|
// It limits the number of worker threads to min(num_workers, num_cpu).
|
||||||
// The function aborts if an error is encountered.
|
// The function aborts if an error is encountered.
|
||||||
// Example: parallel.run([1, 2, 3, 4, 5], 2, fn (i) { println(i) })
|
// Example: parallel.run([1, 2, 3, 4, 5], |i| println(i))
|
||||||
pub fn run[T](input []T, worker fn (T), opt Params) {
|
pub fn run[T](input []T, worker fn (T), opt Params) {
|
||||||
if input.len == 0 {
|
if input.len == 0 {
|
||||||
return
|
return
|
||||||
|
@ -61,7 +61,7 @@ struct Task[T, R] {
|
||||||
// It limits the number of worker threads to max number of cpus.
|
// It limits the number of worker threads to max number of cpus.
|
||||||
// The worker function can return a value. The returning array maintains the input order.
|
// The worker function can return a value. The returning array maintains the input order.
|
||||||
// Any error handling should have happened within the worker function.
|
// Any error handling should have happened within the worker function.
|
||||||
// Example: squares := parallel.amap([1, 2, 3, 4, 5], 2, fn (i) { return i * i })
|
// Example: squares := parallel.amap([1, 2, 3, 4, 5], |i| i * i); assert squares == [1, 4, 9, 16, 25]
|
||||||
pub fn amap[T, R](input []T, worker fn (T) R, opt Params) []R {
|
pub fn amap[T, R](input []T, worker fn (T) R, opt Params) []R {
|
||||||
if input.len == 0 {
|
if input.len == 0 {
|
||||||
return []
|
return []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue