Atomic Smart Pointers
Learn about atomic smart pointers proposed for C++20 concurrency, which improve thread safety, consistency, and performance of shared_ptr usage in multithreaded programs. Understand the importance of type safety and the role of atomic types in preventing data races.
We'll cover the following...
This chapter is about the future of C++. In this chapter, my intent is not to be as precise as I was in the other chapters in this course. That’s for two reasons: First, not all of the presented features will make it into the C++20 standard; second, if a feature makes it into the C++20 standard, the interface of that feature will very likely change. My aim in this chapter is just to give you an idea about the upcoming concurrency features in C++.
Atomic Smart Pointers
A std::shared_ptr consists of a control block and its resource. The control block is thread-safe, but the access to the resource is not. This means modifying ...