Re:Lock-Free Rust: Crossbeam in 2019
by gpderetta on Wednesday January 30, 2019 @11:24AM
(#19036409)
True. IIRC there are ways [1] to implement try lock free updates of reference counted pointers but they are a bit exotic and not cheap.
[1] at the very least you can implement a lock free n-CAS operation given a plain CAS.
With a reference counted pointer, you cannot "read" it without incrementing the count, or else someone else might drop the count to zero and free the memory. You would need hardware support for atomically reading a pointer, dereferencing it, and then incrementing the value at that location.
GC (whether tracing or epoch based), hazard pointers or avoiding dynamic memory allocations in the first place (so all memory is pre-allocated, outside of the lock free parts) are the only solutions to this I'm aware of.