A Lock-Free Atomic Shared Pointer in Modern Cpp
summary
Claims a portable, practical implementation of a lock-free std::atomic<std::shared_ptr> and explains how it actually works: a split refcount algorithm plus tricks like pointer packing and optional refcount batching. Compares GCC/MSVC standard libs (they use mutexes), Folly (production, lock-free via packing), and proof‑of‑concepts (double-width CAS, intrusive or allocation-heavy alias handling). Benchmarks show higher average cost but far better worst‑case latency; discusses aliasing, allocator and portability tradeoffs and which implementations are ready to use.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:03Atomic shared pointers matter
- 7:04Shared pointers thread safety
- 14:29Problem with C++20 atomic shared pointers
- 19:29Existing lock-free implementations
- 27:17How lock-free atomic shared pointers work
- 36:43Alias constructors in lock-free
- 44:42Double-width CAS and CPU compatibility
- 53:51Comparing lock-free implementations
- 57:01Benchmarking lock-free vs mutex
- 1:00:53Future plans and goals
related talks
01h 00mLock-Free Programming (or, Juggling Razor Blades), Part I
01h 05mIntroduction to Wait-free Algorithms in C++ Programming
01h 04mConcurrency TS2: Improved C++ Concurrency and Lock-free Programming
55mThe Memory Model in C++
01h 08mA lock-free concurrent toolkit for hazard pointers
11mAnatomy of a Smart Pointer
50mBack to Basics: Smart Pointers and RAII
01h 40mBack to the Basics! Essentials of Modern C++ Style
