When I'm just curious about the implementation details, I read the C code. And 
as I can tell, it's safe after moving, as `local` is then set to `nil` (, which 
is the side effect of moving.) But the operation of moving can be unsafe, as 
it's unknown if `move` is an atomic operation. You may need a `Lock` to prevent 
the main thread from accessing `g` during the move.
    
    
    var g: X
    proc foreign {.thread.} =
      var local = X(a: "abc")
      {.cast(gcsafe).}:
        g = move local
        # local is now `nil`
      # local is about to be destoryed, but it's now `nil`. No operation.
    # g destroyed.
    
    
    Run

Reply via email to