Search⌘ K

C++20: The Concurrent Future

Explore the advanced concurrency features introduced in C++20. Understand atomic smart pointers, extended futures for composable tasks, synchronization primitives like latches and barriers, coroutines for cooperative multitasking, transactional memory concepts, and task blocks following the fork-join model. This lesson helps you grasp how C++20 enhances concurrent programming by addressing previous limitations and introducing new synchronization and task management tools.

widget

It is difficult to make predictions, especially about the future (Niels Bohr). Therefore, I will make statements about the concurrency features of C++20.

Atomic Smart Pointers

The smart pointers std::shared_ptr and std::weak_ptr have a conceptional issue in concurrent programs: they share an intrinsically mutable state. Therefore, they are prone to data races and, thus, lead to undefined behavior. std::shared_ptr and std::weak_ptr guarantee that the incrementing or decrementing of the reference counter is an atomic operation and the resource will be deleted exactly once, but neither of them can guarantee that the ...