It is not clear to me under which conditions on `T` one can pass `T` around 
between threads. If I run the following program
    
    
    import threadpool
    
    
    type Tree = object
      d: int
      left, right: ref Tree
    
    template `~`[T](a: T): ref T =
      var x: ref T
      new(x)
      x[] = a
      x
    
    proc tree(depth: int): Tree =
      if depth == 0:
        Tree(d: 0)
      else:
        Tree(d: depth, left: ~tree(depth - 1), right: ~tree(depth - 1))
    
    proc main() =
      let t = spawn tree(3)
      sync()
      let s = ^t
      echo s
    
    main()
    

I get the error `Error: cannot create a flowVar of type: Tree`. It must have to 
do something with the self reference, but I am not sure why this limitation 
exists

Reply via email to