A lock-free std::atomic std::shared_ptr
summary
Claims a portable lock-free std::atomic<std::shared_ptr> is implementable using a split refcount design that keeps a control-block pointer and a local refcount in one atomic word, with options of double-width CAS or pointer-packing on 64-bit to make updates atomic. References three open implementations (Anthony Williams, Folly, Vladislav) and shows benchmarks: mutex-backed std::atomic is faster on median cases but lock-free versions give far better worst-case latency; aliasing/allocator edge-cases force trade-offs and the implementation remains work-in-progress.
AI-written summary · about
chapters (14)
- 0:00Start
- 9:35Safety
- 12:20Atomic Shared Pointer
- 22:57Implementation of a Log Free Stack
- 33:24Double Compare and Swap Operation
- 34:17Double Width Compartment Swap
- 47:43The Shared Pointer
- 48:08The Aliasing Constructor
- 1:05:39Possible Solutions
- 1:07:22Pac-Pointers
- 1:21:22Gcc
- 1:22:45Takeaways
- 1:26:41Matrix of Existing Open Source Implementations
- 1:27:19How To Verify that the Code Is Correct
related talks
01h 03mA lock-free atomic shared_ptr
01h 03mSafety: off --- How not to shoot yourself in the foot with C++ atomics
01h 11mLock-Free Programming (or, Juggling Razor Blades), Part II
01h 14m“C++ atomics, from basic to advanced. What do they really do?”
52mNonblocking algorithms/ CAS/Atomics
01h 03mUsing weakly ordered C++ atomics correctly
01h 00mConcurrency in C++20: A Deep Dive
01h 32mLock-free programming with modern C++
