June 2025
Intermediate to advanced
1093 pages
33h 24m
English
With mutexes and locks, you can go very far, and these form the basis of what you need to work with threads. Sometimes, however, handling mutexes and locks is cumbersome. With call_once, you have already seen an alternative way where the standard library assembles the basic building blocks into something new for you. There are a few more of these advanced tools that I will introduce to you here.
A typical scenario with multiple threads is that one produces data and the other waits for it to be ready for processing. These two can communicate with each other via a condition variable condition_variable.
// https://godbolt.org/z/c9x6xT8dr#include <thread>#include <mutex>#include <condition_variable> ...
Read now
Unlock full access