Moving a tree around has never been easier:
import std / [json, isolation]
import threading / channels
var chan = newChan[JsonNode]()
var thr: Thread[void]
proc worker() {.thread.} =
var x: JsonNode
chan.recv(x) # somebody should fix this API...
echo "received ", x
createThread thr, worker
#chan.send unsafeIsolate(%* {"key": 2, "keyB": "value"})
chan.send isolate(%* {"key": 2, "keyB": "value"}) # JSON nodes do form a
tree
joinThread thr
Run
No need for "manual locking in 2023", but locking is still awesome anyway IMHO.
;-) Much easier to reason about than any message passing system or "actor
model" that I've seen so far. But that's off-topic.