Hello.
I can compile the following code with gc:refc but not with gc:orc. Am I missing something? I had to use n.unsafeaddr for reasons unknown to me. who can shed some light on this for me? must be something special going on with for loop variable n.
#[
nim c -r --gc:refc --threads:on sometest
nim c -r --gc:orc --threads:on sometest
]#
{.experimental.}
import json, threadpool
proc job(node: ptr JsonNode) =
echo node[].type # JsonNode
let key1 = node[]["key"] # Error: invalid control flow for 'parallel'
var nodes: JsonNode = parseJson("""
{ "res": [{"key":"val1"},{"key":"val2"}] } """)["res"]
parallel:
for n in nodes:
spawn job(n.unsafeaddr)
Interesting :
#[
nim c -r --gc:refc --threads:on sometest
nim c -r --gc:orc --threads:on sometest
]#
{.experimental.}
import json, threadpool
proc job(node: ptr JsonNode) =
# echo node
let key1 = node[]["key"] # Error: invalid control flow for 'parallel'
echo key1
var nodes: JsonNode = parseJson("""
{ "res": [{"key":"val1"},{"key":"val2"}] } """)["res"]
parallel:
for n in nodes:
spawn job(n.unsafeaddr)
with refc - output is:
"val1"
"val2"
with refc and uncommented line echo node:
{"key":"val1"}
{"key":"val2"}
"val2"
"val2"
why val2 two times??
with orc - not compiles - Error: invalid control flow for 'parallel'