Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> and then if it is zero, we need an atomic memory_order_release decrement for the remote reference count.

Actually, we don't. We need a atomic load, but if the results of that load indicate that we're destroying the last reference to the object (which does need to be more complicated than just a extra remote reference; see [0] and [1]), we can just destroy the object as-is without actually doing a atomic store, because by definition there is no reference to the object through which another thread could inspect the remote refcount. (If there was, our reference wouldn't be the last one.)

0: https://news.ycombinator.com/item?id=28883218

1: https://sci-hub.se/https://dl.acm.org/doi/10.1145/3243176.32...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: