So I end up with:
Code:
lock mutex;
while(true)
{
wait for condition;
if(vector != empty)
{
newvec = vector;
vector.clear();
unlock mutex;
consume_all(newvec);
lock mutex;
}
}
unlock mutex;
but what if a thing is produced between consume_all and lock? wouldn't it be better to remove the unlock/lock from the inner if?