[Boost-bugs] [Boost C++ Libraries] #12727: Using sleep_for with nanoseconds on a boost::thread does not always use the correct clock

Subject: [Boost-bugs] [Boost C++ Libraries] #12727: Using sleep_for with nanoseconds on a boost::thread does not always use the correct clock
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-01-05 09:13:59


#12727: Using sleep_for with nanoseconds on a boost::thread does not always use the
correct clock
------------------------------+----------------------
 Reporter: rkaris@… | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost 1.63.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------
 When BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC is defined on a
 pthreads-based platform, a sleep_for with nanoseconds on a boost::thread
 will wait much longer than expected.

 To reproduce:

 {{{
 #define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC

 #include <boost/thread.hpp>
 #include <boost/chrono.hpp>

 int main(int, char**)
 {
     auto sleep200ns = [] () {
 boost::this_thread::sleep_for(boost::chrono::nanoseconds(200)); };

     sleep200ns(); // Works

     boost::thread t([&] ()
     {
         sleep200ns(); // Waits for a much longer period
     });

     t.join();

     return 0;
 }
 }}}

 Digging into the underlying code indicates the use of CLOCK_REALTIME,
 which does not seem to play well with the different clock of the condition
 variables which are used to perform the wait.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12727>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC