Just played around a bit with your example and unless I create the object
entirely within the isolate call it doesn't work. This really limits what
you're able to do with this since I can't create stuff outside the isolate call
and then isolate them after the fact, and I'm not able to isolate something
first and then edit it afterwards. E.g. something like this is not possible:
import std / [json, isolation]
import threading / channels
type
Test = ref object
data: string
Tree = ref object
left, right: Test
var chan = newChan[Tree]()
var thr: Thread[void]
proc worker() {.thread.} =
var x: Tree
chan.recv(x) # somebody should fix this API...
echo "received ", x.left.data, " ", x.right.data
createThread thr, worker
let hello = Test(data: "Hello")
chan.send isolate(Tree(left: hello, right: Test(data: "world")))
joinThread thr
Run
because it can't isolate that `let hello`. I fail to see how this would be
useful for anything more complicated than an example like this, if you have
anything which does actual work with this I'm super curious to see how it's
supposed to work.
On another note running it through Valgrind/Helgrind I get 3 errors, one of
which is the aforementioned issue and two others about possible data races. I'm
running this command to test it: `nim c --passC:-g --passL:-g -d:useMAlloc
araqtree.nim && valgrind --tool=helgrind ./araqtree` so it seems like it still
doesn't work quite as well as we'd like it to..