...
The std::condition_variable::wait()
function has an overloaded form that accepts a function object representing the predicate. This form of wait()
behaves as if it were implemented as while (!pred()) wait(lock);
. This compliant solution uses a lambda as a predicate and passes it to the wait()
function. The predicate is expected to return true when it is safe to proceed, which reverses the predicate logic from the compliant solution using an explicit loop predicate.
...