I'm experimenting a bit with parallel (my main goal is to implement a simple parallel loop - that's all).
I've imported threadpool with --threads:on and {.experimental: "parallel".}.
Here's the code in question:
parallel:
for item in collection:
discard spawn doSomethingWith(item)
However, I keep getting an error:
../code/test.nim(124, 31) template/generic instantiation of `nimCreateFlowVar` from here
../.choosenim/toolchains/nim-1.2.6/lib/pure/concurrency/threadpool.nim(214, 6) Error: cannot bind another '=destroy' to: FlowVarObj; previous declaration was constructed here implicitly: ../.choosenim/toolchains/nim-1.2.6/lib/pure/concurrency/threadpool.nim(211, 48)
Any idea what is going on? (or any other idea how to implement a proper parallel loop?)
There is a bug in either threadpool or in parallel introduced by the new destructor changes.
I tried to use parallel myself and never managed to besides the example in the experimental manual (and I wrote an entire multithreading library Weave).
Just use the plain threadpool:
for item in collection:
discard spawn doSomethingWith(item)