Re: [Boost-bugs] [Boost C++ Libraries] #6787: boost::thread::sleep() hangs if system time is rolled back

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6787: boost::thread::sleep() hangs if system time is rolled back
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-12-09 15:17:06


#6787: boost::thread::sleep() hangs if system time is rolled back
-----------------------------------------------+----------------------
  Reporter: Artem Gayardo-Matrosov <boost@…> | Owner: viboes
      Type: Bugs | Status: reopened
 Milestone: Boost 1.57.0 | Component: thread
   Version: Boost 1.49.0 | Severity: Problem
Resolution: | Keywords:
-----------------------------------------------+----------------------

Comment (by Matulis):

 Replying to [comment:24 viboes]:
> Even with boost::this_thread::no_interruption_point::sleep_for?
>
> Well, it is not easy to manage the specific GCC bugs.

 And what I meant with the GCC comment, is that the only way I have gotten
 the situation to work correctly is if I used
 std::this_thread::sleep_for().

 Yes, even with boost::this_thread::no_interruption_point::sleep_for:

 Here is the sample code(modified from an above example)

 #include <iostream>

 #include <boost/thread.hpp>
 using namespace std;

 void testfunc() {

         int i = 0;
         while(true) {
           //Turn system clock back now and loop will no longer print
                 std::cout << "Testing: " << i << std::endl;
                 boost::this_thread::no_interruption_point::sleep_for(
 boost::chrono::milliseconds(800));
                 i++;
         }
 }

 int main() {

         boost::thread th = boost::thread(&testfunc);
         th.join();

         return 0;
 }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6787#comment:25>
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:17 UTC