I am developing a windows app in C++ in VS2017 I have to perform some data(stored in queue) processing in a thread, but only when items exist in a queue.
thread
{
if(!queue.empty()
{
//process data and pop out
}
}
But there are chances when queue mayb empty and sometimes have data, so how can i acheive this?
I tried to run whole loop in thread , but that isn't effective and optimized ad application becomes unresponsive after some time
thread
{
while(true)
{
if(!queue.empty()
{
//process data and pop out
}
}
}
Please support and help in knowing how can this be done effectively?