I think I know the reason why `ref` variables on ARC/ORC are considered 
generally non-lockable. It's because their destructors are called automatically 
when going out of scope, without the protection of a lock, which can cause 
undefined behavior when there're other referencers from other threads. The only 
solution seems to be destroying them manually with a lock hold, which is no 
more convenient than manual memory management.

Atomic refcounting works, however, because the access to heap memory is 
protected by atomic operations even when the ref variable goes out of the 
scope, and thus prevents races.

Reply via email to