I was looking at the possible solution to synchronise a bounded buffer ( like queue) using condition variables and think that we probably need two condition variables to correctly implement the synchronisation, one condition varaible will have a queue where the consumer thread(s) will be waiting to see if the buffer is not empty and another will producer (threads) will be waiting to check if the buffers are not full?

This is a common problem in multi-threaded applications. You will need to use a mutex to syncronize the producer/consumer threads. Using condition variables is not safe enough, especially in high throughput applications. I write a lot of this sort of code in my job. We have to deal with it very precisely, and variables are not enough.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.