https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80538

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Thu Oct 11 16:37:23 2018
New Revision: 265044

URL: https://gcc.gnu.org/viewcvs?rev=265044&root=gcc&view=rev
Log:
PR libstdc++/80538 Only call sleep for non-zero values

Avoid a system call when no sleep is required. Sleep in a loop (actually
two loops) to handle interruption by signals.

        PR libstdc++/80538
        * src/c++11/thread.cc (this_thread::__sleep_for)
        [_GLIBCXX_HAVE_SLEEP]: Only call sleep for non-zero values.
        Loop while sleep call is interrupted and until steady_clock
        shows requested duration has elapsed.
        (!_GLIBCXX_HAVE_USLEEP]: Use the _GLIBCXX_HAVE_SLEEP code path, but
        avoiding the usleep call.
        * testsuite/30_threads/this_thread/60421.cc: Test repeated
        signal interruptions.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/src/c++11/thread.cc
    trunk/libstdc++-v3/testsuite/30_threads/this_thread/60421.cc

Reply via email to