Works just fine:
import std / [json, isolation]
import threading / channels
type
Test = ref object
data: string
Branch = ref object
data: string
Tree = ref object
left, right: Branch
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
proc createTree(hello: Test): Tree =
Tree(left: Branch(data: "Hello"), right: Branch(data: "world"))
createThread thr, worker
chan.send isolate(createTree(Test(data: "Hello")))
joinThread thr
Run
`isolated` doesn't reason about variables and never claimed to do.
But this is all somewhat besides the point. The point is:
If you think isolation is worth pursuing, show real-world examples or just a
set of benchmarks where it works out. Ideally with green sanitizers. You can
use `unsafeIsolate` for this, so that we can identify idioms that `isolate`
must support. Or we can think of adding this runtime check for isolation.
But as long as I have no feedback whatsoever beyond "it sucks because there is
no checking and also my data is not isolated" (<\-- SO WHICH ONE IS IT?) I'm
unwilling to invest any further time in this.