Condition Variables
This lesson explains condition variable such as wait s and their usage in C++ for multithreading purposes.
We'll cover the following...
Condition variables enable threads to be synchronized via messages. They need the <condition_variable>
header, one thread to act as a sender, and the other as the receiver of the message; the receiver waits for the notification from the sender. Typical use cases for condition variables are sender-receiver or producer-consumer workflows.
A condition variable can be the sender but also the receiver of the message.
Method | Description |
---|---|
cv.notify_one() |
Notifies a waiting thread. |
cv.notify_all() |
Notifies all waiting |
Access this course and 1400+ top-rated courses and projects.