There are 2 overloads of std::condition_variable::wait
:
void wait( std::unique_lock<std::mutex>& lock ); | (1) | (since C++11) |
---|---|---|
template< class Predicate > void wait( std::unique_lock<std::mutex>& lock, Predicate pred ); | (2) | (since C++11) |
(1) just waits on the lock. It is subject to spurious wakeup. |
(2) is equivalent to the following:
while (!pred) {
wait();
}