You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lock-free implementations [of refcounting] rely on a compare-and-swap mechanism on the wrapped pointer – here, the pointer is not wrapped. This sucks, but if we make the assumption that no destruction shall happen during an async context, it’s kind of fine
This doesn’t make sense to me. I’ve implemented ref-counting a few times; it uses atomic increment/decrement of the refcount field, not the pointer to the object. When the decremented refcount hits zero you free the object, with no thread-safety issues because by definition only the current thread has a reference to it.
This assumes an “intrusive refcount” stored in the object's metadata. The C++ shared_ptr avoids that but it requires allocating a separate block containing the refcount and a pointer to the object, and the shared_ptr itself is a pointer to that block. That seems far too awkward to use in C since it required a double dereference.
The text was updated successfully, but these errors were encountered:
In the blog post you wrote:
This doesn’t make sense to me. I’ve implemented ref-counting a few times; it uses atomic increment/decrement of the refcount field, not the pointer to the object. When the decremented refcount hits zero you free the object, with no thread-safety issues because by definition only the current thread has a reference to it.
This assumes an “intrusive refcount” stored in the object's metadata. The C++ shared_ptr avoids that but it requires allocating a separate block containing the refcount and a pointer to the object, and the shared_ptr itself is a pointer to that block. That seems far too awkward to use in C since it required a double dereference.
The text was updated successfully, but these errors were encountered: