title: Why does std::future::wait_for not wait for the correct duration?
body: <p>I don't understand why the discrepancy between the measured and the specified durations when calling <code>std::future::wait_for</code> increases when the specified duration increases.</p>
  
  <p>When I tell a <code>std::future</code> to wait for 10ns and measure the elapsed time I get ~2000ns. Now, 10ns is a very short duration, so maybe there's too much overhead involved with the associated function calls to wait for this short amount of time. But when I tell a <code>std::future</code> to wait for 100000ns and measure the elapsed time I get ~150000ns. A similar effect can be seen when waiting for 10 and 100 microseconds, respectively.</p>
  
  <pre><code>#include &lt;chrono&gt;
  #include &lt;future&gt;
  #include &lt;iostream&gt;
  #include &lt;thread&gt;
  
  using namespace std::chrono;
  using namespace std::chrono_literals;
  
  void f() { std::this_thread::sleep_for(1s); }
  
  int main() {
    steady_clock::time_point start, end;
  
    std::future&lt;void&gt; future = std::async(std::launch::async, f);
  
    start = steady_clock::now();
    future.wait_for(10ns);
    end = steady_clock::now();
    std::cout &lt;&lt; "10 -&gt; " &lt;&lt; (end - start).count() &lt;&lt; '\n';
  
    start = steady_clock::now();
    future.wait_for(100000ns);
    end = steady_clock::now();
    std::cout &lt;&lt; "100000 -&gt; " &lt;&lt; (end - start).count() &lt;&lt; '\n';
  
    return 0;
  }
  </code></pre>
  
  <p>I compile the above code with <code>g++ future_test.cpp -lpthread</code>, with g++ 7.3.0 on Ubuntu 18.04.</p>
  
  <p>I could explain something like</p>
  
  <pre><code>10 -&gt; 2000
  100000 -&gt; 102000
  </code></pre>
  
  <p>But that's not what I get. Here's a representative result of multiple executions:</p>
  
  <pre><code>10 -&gt; 2193
  100000 -&gt; 154723
  </code></pre>
  
  <p>Why is the measured duration for 100'000ns more than ~2'000ns from the specified duration?</p>