title: Unexpected results with async in c++
body: <p>I am approaching parallel programming in C++ and, as I am working with functions which return a value, I decided to use <code>std::async</code> with <code>future</code> objects. In particular, I am parallelizing an integrator. I have a function <code>integrate(const std::vector&lt;double&gt;&amp; v, double h)</code> which computes the integral under the function stored in <code>v</code>. </p>
  
  <p>I first tried the function with a long vector and recorded the time, then I divided the vector in three subvectors and integrated simultanely the three different subvectors. However, the second time is always longer than the first, and this is not possible. What am I doing wrong?</p>
  
  <pre><code>double a;
  
  const clock_t begin_time1 = clock();
  a=integral(v1, h);
  cout &lt;&lt; double( clock () - begin_time1 ) /  CLOCKS_PER_SEC &lt;&lt; endl;
  
  future&lt;double&gt; f1, f2,f3;
  const clock_t begin_time2 = clock();
  f1 = async(launch::async, integral, ref(sv1), h);
  f2 = async(launch::async, integral, ref(sv2), h);
  f3 = async(launch::async, integral, ref(sv3), h);
  cout &lt;&lt; double( clock () - begin_time2 ) /  CLOCKS_PER_SEC &lt;&lt; endl;
  
  cout &lt;&lt; a &lt;&lt; "  " &lt;&lt; f1.get()+f2.get()+f3.get() &lt;&lt; endl;
  </code></pre>
  
  <p>EDIT: 
  I solved it. clock() gives the CPU time, I needed of course the real time. 
  steady_clock() did the job.</p>