Atomic Support in C++
Learn about atomic support in C++ through the standard library's atomic variables, lock-free property, flags, and wait/notify operations.
We'll cover the following
Atomic variables in the standard library
The standard library contains support for atomic variables, sometimes called atomics. An atomic variable is a variable that can safely be used and mutated from multiple threads without introducing data races.
Do you remember the data race example we looked at earlier where two threads updated a global counter? We solved it by adding a mutex lock together with the counter. Instead of using an explicit lock, we could have used a std::atomic<int>
instead:
Get hands-on with 1400+ tech skills courses.