Re: [Boost-bugs] [Boost C++ Libraries] #8006: Boost::Chrono Assertion at startup - steady_clock::now() - Windows

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8006: Boost::Chrono Assertion at startup - steady_clock::now() - Windows
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-09 06:27:28


#8006: Boost::Chrono Assertion at startup - steady_clock::now() - Windows
-------------------------------+----------------------
  Reporter: meckschlager@… | Owner: viboes
      Type: Bugs | Status: assigned
 Milestone: To Be Determined | Component: chrono
   Version: Boost 1.50.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+----------------------

Comment (by viboes):

 Please, could you try this patch


 {{{
 diff --git a/include/boost/chrono/detail/inlined/win/chrono.hpp
 b/include/boost/chrono/detail/inlined/win/chrono.hpp
 index 84cac01..e2128d6 100644
 --- a/include/boost/chrono/detail/inlined/win/chrono.hpp
 +++ b/include/boost/chrono/detail/inlined/win/chrono.hpp
 @@ -38,12 +38,19 @@ namespace chrono_detail
      static double nanosecs_per_tic =
 chrono_detail::get_nanosecs_per_tic();

      boost::detail::winapi::LARGE_INTEGER_ pcount;
 - if ( (nanosecs_per_tic <= 0.0L) ||
 - (!boost::detail::winapi::QueryPerformanceCounter( &pcount ))
 )
 + if ( nanosecs_per_tic <= 0.0L )
      {
 - BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
 + BOOST_ASSERT(0 && "Boost::Chrono - get_nanosecs_per_tic Internal
 Error");
        return steady_clock::time_point();
      }
 + unsigned times=0;
 + while ( ! boost::detail::winapi::QueryPerformanceCounter( &pcount ) )
 + {
 + if ( ++times > 3 ) {
 + BOOST_ASSERT(0 && "Boost::Chrono - QueryPerformanceCounter
 Internal Error");
 + return steady_clock::time_point();
 + }
 + }

      return steady_clock::time_point(steady_clock::duration(
        static_cast<steady_clock::rep>((nanosecs_per_tic) *
 pcount.QuadPart)));

 }}}

 Giving as result

 {{{
   steady_clock::time_point steady_clock::now() BOOST_NOEXCEPT
   {
     static double nanosecs_per_tic =
 chrono_detail::get_nanosecs_per_tic();

     boost::detail::winapi::LARGE_INTEGER_ pcount;
     if ( nanosecs_per_tic <= 0.0L )
     {
       BOOST_ASSERT(0 && "Boost::Chrono - get_nanosecs_per_tic Internal
 Error");
       return steady_clock::time_point();
     }
     unsigned times=0;
     while ( ! boost::detail::winapi::QueryPerformanceCounter( &pcount ) )
     {
       if ( ++times > 3 ) {
         BOOST_ASSERT(0 && "Boost::Chrono - QueryPerformanceCounter
 Internal Error");
         return steady_clock::time_point();
       }
     }

     return steady_clock::time_point(steady_clock::duration(
       static_cast<steady_clock::rep>((nanosecs_per_tic) *
 pcount.QuadPart)));
   }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8006#comment:19>
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:15 UTC