What are common uses of condition variables in C++?
- by jasonline
I'm trying to learn about condition variables. I would like to know what are the common situations where condition variables are used.
One example is in a blocking queue, where two threads access the queue - the producer thread pushes an item into the queue, while the consumer thread pops an item from the queue. If the queue is empty, the consumer thread is waiting until a signal is sent by the producer thread.
What are other design situations where you need a condition variable to be used?