aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMike Crowe <mac@mcrowe.com>2019-12-02 16:23:06 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2019-12-02 16:23:06 +0000
commita7334019b11798a9e791edef62a690b521e78a5b (patch)
tree498509b78868b1b78e45cd8b030fa1f557a57d41 /gcc
parent3b2fb54353d29ae7c6067ebc78549d1296b1340d (diff)
downloadgcc-a7334019b11798a9e791edef62a690b521e78a5b.zip
gcc-a7334019b11798a9e791edef62a690b521e78a5b.tar.gz
gcc-a7334019b11798a9e791edef62a690b521e78a5b.tar.bz2
libstdc++: Fix timed_mutex::try_lock_until on arbitrary clock (PR 91906)
A non-standard clock may tick more slowly than std::chrono::steady_clock. This means that we risk returning false early when the specified timeout may not have expired. This can be avoided by looping until the timeout time as reported by the non-standard clock has been reached. Unfortunately, we have no way to tell whether the non-standard clock ticks more quickly that std::chrono::steady_clock. If it does then we risk returning later than would be expected, but that is unavoidable and permitted by the standard. 2019-12-02 Mike Crowe <mac@mcrowe.com> PR libstdc++/91906 Fix timed_mutex::try_lock_until on arbitrary clock * include/std/mutex (__timed_mutex_impl::_M_try_lock_until): Loop until the absolute timeout time is reached as measured against the appropriate clock. * testsuite/util/slow_clock.h: New file. Move implementation of slow_clock test class. * testsuite/30_threads/condition_variable/members/2.cc: Include slow_clock from header. * testsuite/30_threads/shared_timed_mutex/try_lock/3.cc: Convert existing test to templated function so that it can be called with both system_clock and steady_clock. * testsuite/30_threads/timed_mutex/try_lock_until/3.cc: Also run test using slow_clock to test above fix. * testsuite/30_threads/recursive_timed_mutex/try_lock_until/3.cc: Likewise. * testsuite/30_threads/recursive_timed_mutex/try_lock_until/4.cc: Add new test that try_lock_until behaves as try_lock if the timeout has already expired or exactly matches the current time. From-SVN: r278902
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions