In the code example at [the thread @brainproxy 
mentioned](https://forum.nim-lang.org/t/11203) are some problems that make it 
unsafe, including:

  * In the thread, a _variable_ of a `ref` type is created and assigned to, 
which increases the reference count by one. As "increasing the reference count" 
is not an atomic operation, this result in a data race.
  * After the variable of `ref` type is created and assigned to in a thread, it 
is destroyed (at end of the block), which decreases the reference count by one. 
As "decreasing the reference count" is not an atomic operation, this result in 
a data race.



However, I believe arguments/parameters don't do the same as above; they don't 
increase/decrease the reference counts as variables do. At least I believe so 
on ARC/ORC. As a result, I see none of the problems in your code, and I also 
don't understand. But it's unknown if allocating memory is an atomic operation. 
Maybe not.

P.S. If you want to go further, look at the generated C or asm code. That's 
where you'll see a difference.

Reply via email to