title: std::condition_variable::wait with predicate
body: <p>In the documentation for std::condition_variable, there is an overload of wait() taking as argument a predicate function. The function will wait until the first wake_up at which the predicate function is true.</p>
  <p>In the <a href="http://en.cppreference.com/w/cpp/thread/condition_variable/wait" rel="noreferrer">documentation</a></p>
  <p>It is stated that this is equivalent to:</p>
  <pre><code>while (!pred()) {
      wait(lock);
  }
  </code></pre>
  <p>But also:</p>
  <blockquote>
  <p>This overload may be used to ignore spurious awakenings while waiting for a specific condition to become true. Note that before enter to this method lock must be acquired, after wait(lock) exits it is also reacquired, i.e. lock can be used as a guard to pred() access.</p>
  </blockquote>
  <p>I'm not sure to understand, are these strictrly equivalent (in which case I prefer the plain while loop which is easier to read than the overload with a lambda in my case), or is the overload (possibly implementation depending) more efficient?</p>
  <p>Could an implementation evaluate the predicate in the notifying thread before awakening the waiting thread, in order to avoid awakening when the test condition is false? c++ thread guru needed here...</p>
  <p>Thanks</p>