sync() simply waits till all your spawned threads are finished. If you call
spawn n-times on the same proc it´s almost the same as parallel except that
parallel does some additionally checks for you. Also you don't need to collect
the FLowVars and check manually with ^ (on each FlowVar) (or use
Good call.
[The
doco](https://nim-lang.org/docs/manual.html#parallel-spawn-parallel-statement)
doesn't use the `sync()`
Indeed Jack, I think sync() is nonsense when parallel statement is used.
what does the call to sync() do?
from [this post](https://forum.nim-lang.org/t/3257/2)
convert something like the following to suit your specific usage
var
LoopSz = faces.len
res: array[LoopSz, int]
parallel:
for i in 0..LoopSz-1:
spawn whateverNeedsDoingInParallel(...,
I would suggest you check this page: [10 Nim One Liners to Impress Your
Friends](https://blog.ubergarm.com/blog/archive/archive-ten-nim-one-liners.md),
and also, check my own implementation of a parallel map with some improvements
here:
I would like some guidance on how to best parallelize this loop. I've played
around with the parallel: macro, and using spawn, but haven't gotten a working
solution yet. It isn't entirely clear what the best approach should be:
for i,face in faces: #face is a path to an image file