Re: [Boost-bugs] [Boost C++ Libraries] #10967: Timed wait points inconsistently convert relative to absolute waits

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10967: Timed wait points inconsistently convert relative to absolute waits
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-01-25 10:12:08


#10967: Timed wait points inconsistently convert relative to absolute waits
-------------------------------+----------------------
  Reporter: ned14 | Owner: viboes
      Type: Bugs | Status: assigned
 Milestone: To Be Determined | Component: thread
   Version: Boost 1.57.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+----------------------

Comment (by viboes):

 The following code seems to be using do_wait incorrectly, it gives a
 relative instead of an absolute time, isn't it?


 {{{
         template <class Clock, class Duration>
         cv_status
         wait_until(
                 unique_lock<mutex>& lock,
                 const chrono::time_point<Clock, Duration>& t)
         {
           using namespace chrono;
           chrono::time_point<Clock, Duration> now = Clock::now();
           if (t<=now) {
             return cv_status::timeout;
           }
           do_wait(lock, ceil<milliseconds>(t-now).count());
           return Clock::now() < t ? cv_status::no_timeout :
                                              cv_status::timeout;
         }

         template <class Rep, class Period>
         cv_status
         wait_for(
                 unique_lock<mutex>& lock,
                 const chrono::duration<Rep, Period>& d)
         {
           using namespace chrono;
           if (d<=chrono::duration<Rep, Period>::zero()) {
             return cv_status::timeout;
           }

           steady_clock::time_point c_now = steady_clock::now();
           do_wait(lock, ceil<milliseconds>(d).count());
           return steady_clock::now() - c_now < d ? cv_status::no_timeout :
                                                    cv_status::timeout;
         }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10967#comment:4>
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