Re: [Boost-bugs] [Boost C++ Libraries] #8323: boost::thread::try_join_for/try_join_until may block indefinitely due to a combination of problems in Boost.Thread and Boost.Chrono

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8323: boost::thread::try_join_for/try_join_until may block indefinitely due to a combination of problems in Boost.Thread and Boost.Chrono
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-03-30 14:05:10


#8323: boost::thread::try_join_for/try_join_until may block indefinitely due to a
combination of problems in Boost.Thread and Boost.Chrono
-----------------------------------------+----------------------------------
  Reporter: szakharchenko@… | Owner: viboes
      Type: Bugs | Status: assigned
 Milestone: To Be Determined | Component: thread
   Version: Boost 1.50.0 | Severity: Problem
Resolution: | Keywords: thread, chrono, steady_clock, try_jon_for, try_join_until, QueryPerformanceCounter
-----------------------------------------+----------------------------------

Comment (by viboes):

 I see the problem now.

 Could you try to replace


 {{{
         template <class Clock, class Duration>
         bool try_join_until(const chrono::time_point<Clock, Duration>& t)
         {
           using namespace chrono;
           system_clock::time_point s_now = system_clock::now();
           typename Clock::time_point c_now = Clock::now();
           return try_join_until(s_now + ceil<nanoseconds>(t - c_now));
         }
 }}}

 by


 {{{
         template <class Clock, class Duration>
         bool try_join_until(const chrono::time_point<Clock, Duration>& t)
         {
           using namespace chrono;
           system_clock::time_point s_now = system_clock::now();
           bool joined= false;
           do {
             typename Clock::duration d =
 ceil<nanoseconds>(t-Clock::now());
             if (d < Clock::duration::zero()) return false; // in case the
 Clock::time_point t is already reached
             joined = try_join_until(s_now + d);
           } while (! joined);
           return true;
         }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8323#comment:6>
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:12 UTC