A Lock-Free std::atomic< std::shared_ptr >

By Timur Doumler

std::shared_ptr is a standard smart pointer utility widely used in modern C++. A commonly overlooked property of std::shared_ptr is that while its control block is thread-safe, the shared_ptr itself isn’t. To fix this, C++20 introduced std::atomic<std::shared_ptr>. However, existing implementations are typically not lock-free, rendering std::atomic<std::shared_ptr> useless for low-latency and real-time applications.

What would it take to implement a lock-free atomic shared_ptr? In this talk, we first discuss the motivation and use case, review how std::shared_ptr works and the history of std::atomic<std::shared_ptr>. We then look at existing implementations and different implementation strategies. Finally, we present a new implementation of a lock-free atomic shared_ptr which is portable to multiple platforms.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.