title: How to use a condition_variable to really wait_for no longer than a certain duration
body: <p>As <a href="http://www.cplusplus.com/reference/condition_variable/condition_variable/wait_for/">it turns out</a>, <code>condition_variable::wait_for</code> should really be called <code>condition_variable::wait_for_or_possibly_indefinitely_longer_than</code>, because it needs to reacquire the lock before really timing out and returning.</p>
  
  <p>See <a href="http://coliru.stacked-crooked.com/a/b47efc0b7731f2b1">this program</a> for a demonstration.</p>
  
  <p>Is there a way to express, "Look, I really only have <strong>two</strong> seconds. If <code>myPredicate()</code> is still false at that time and/or the lock is still locked, I don't care, just carry on regardless and give me a way to detect that."</p>
  
  <p>Something like:</p>
  
  <pre><code>bool myPredicate();
  auto sec = std::chrono::seconds(1);
  
  bool pred;
  std::condition_variable::cv_status timedOut;
  
  std::tie( pred, timedOut ) =
      cv.really_wait_for_no_longer_than( lck, 2*sec, myPredicate );
  
  if( lck.owns_lock() ) {
      // Can use mutexed resource.
      // ...
      lck.unlock();
  } else {
      // Cannot use mutexed resource. Deal with it.
  };
  </code></pre>