I noticed that when I'm performing a wait operation on a condition variable, it immediately returns. The consequence is that, when executing the following dummy code, 100% of one CPU is being used in the loop :
int main(void) {
boost::condition_variable cond;
boost::mutex mut;
bool data_ready = false;
boost::unique_lock<boost::mutex> lock(mut);
while (!data_ready) {
cond.wait(lock);
}
return 1;
}
I would expect the call to cond.wait(lock)
to put the thread in a state where it's not consuming any CPU but that's not the case.
So where's the problem ? I took the above code from the boost documentation.
(I'm using boost 1.44)
Thanks,
Guillaume