We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Lock-free Atomic Shared Pointers Without a Split Reference Count? It Can Be Done! - Daniel Anderson
Learn how to create lock-free atomic shared pointers without a split reference count, a key innovation in modern concurrency techniques, with a deep dive into the benefits and challenges of this approach.
- A shared pointer without a split reference count is not thread-safe.
- The main problem is solving the use-after-free issue when deleting a shared pointer.
- To avoid this, consider using the split reference count technique, which adds a local reference count for the shared pointer.
- Lock-free atomic shared pointers are possible without using locks.
- The key idea is to use a local reference count for the shared pointer, which is incremented and decremented atomically.
- The local reference count is used to protect the control block and prevent use-after-free issues.
- The control block is only deleted when the local reference count reaches zero.
- Deferred reclamation can be used to implement the split reference count technique.
- The technique is already used in some production libraries, such as Folly.
- Other techniques, like hazard pointers, can also be used to solve the use-after-free issue.
- The technique is not without its challenges, such as dealing with cache effects and aliasing.