Commit 29b26763 by Mike Crowe Committed by Jonathan Wakely

Use steady_clock to implement condition_variable::wait_for with predicate

In r263225 (d2e378182a12d68fe5caeffae681252662a2fe7b), I fixed
condition_variable::wait_for to use std::chrono::steady_clock for the wait.
Unfortunately, I failed to spot that the same fix is required for the
wait_for variant that takes a predicate too.

2018-09-25  Mike Crowe  <mac@mcrowe.com>

	* include/std/condition_variable (condition_variable::wait_for): Use
	steady clock in overload that uses a predicate.

From-SVN: r264575
parent 16d30bbd
2018-09-25 Mike Crowe <mac@mcrowe.com>
* include/std/condition_variable (condition_variable::wait_for): Use
steady clock in overload that uses a predicate.
2018-09-25 Jonathan Wakely <jwakely@redhat.com> 2018-09-25 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/87431 PR libstdc++/87431
......
...@@ -158,11 +158,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -158,11 +158,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const chrono::duration<_Rep, _Period>& __rtime, const chrono::duration<_Rep, _Period>& __rtime,
_Predicate __p) _Predicate __p)
{ {
using __dur = typename __clock_t::duration; using __dur = typename __steady_clock_t::duration;
auto __reltime = chrono::duration_cast<__dur>(__rtime); auto __reltime = chrono::duration_cast<__dur>(__rtime);
if (__reltime < __rtime) if (__reltime < __rtime)
++__reltime; ++__reltime;
return wait_until(__lock, __clock_t::now() + __reltime, std::move(__p)); return wait_until(__lock, __steady_clock_t::now() + __reltime,
std::move(__p));
} }
native_handle_type native_handle_type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment