BVB Source Codes

mars Show thread_clock.hpp Source code

Return Download mars: download thread_clock.hpp Source code - Download mars Source code - Type:.hpp
  1. //  boost thread_clock.cpp  -----------------------------------------------------------//
  2.  
  3. //  Copyright 2010 Vicente J. Botet Escriba
  4.  
  5. //  Distributed under the Boost Software License, Version 1.0.
  6. //  See http://www.boost.org/LICENSE_1_0.txt
  7.  
  8. //  See http://www.boost.org/libs/chrono for documentation.
  9.  
  10. //--------------------------------------------------------------------------------------//
  11. #ifndef BOOST_CHRONO_DETAIL_INLINED_WIN_THREAD_CLOCK_HPP
  12. #define BOOST_CHRONO_DETAIL_INLINED_WIN_THREAD_CLOCK_HPP
  13.  
  14. #include <boost/chrono/config.hpp>
  15. #include <boost/chrono/thread_clock.hpp>
  16. #include <cassert>
  17.  
  18. #include <boost/detail/winapi/GetLastError.hpp>
  19. #include <boost/detail/winapi/GetCurrentThread.hpp>
  20. #include <boost/detail/winapi/GetThreadTimes.hpp>
  21.  
  22. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost
  23. {
  24. namespace chrono
  25. {
  26.  
  27. #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
  28. thread_clock::time_point thread_clock::now( system::error_code & ec )
  29. {
  30.     //  note that Windows uses 100 nanosecond ticks for FILETIME
  31.     mars_boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
  32.  
  33.     if ( mars_boost::detail::winapi::GetThreadTimes(
  34.             mars_boost::detail::winapi::GetCurrentThread (), &creation, &exit,
  35.             &system_time, &user_time ) )
  36.     {
  37.         duration user = duration(
  38.                 ((static_cast<duration::rep>(user_time.dwHighDateTime) << 32)
  39.                         | user_time.dwLowDateTime) * 100 );
  40.  
  41.         duration system = duration(
  42.                 ((static_cast<duration::rep>(system_time.dwHighDateTime) << 32)
  43.                         | system_time.dwLowDateTime) * 100 );
  44.  
  45.         if (!BOOST_CHRONO_IS_THROWS(ec))
  46.         {
  47.             ec.clear();
  48.         }
  49.         return time_point(system+user);
  50.  
  51.     }
  52.     else
  53.     {
  54.         if (BOOST_CHRONO_IS_THROWS(ec))
  55.         {
  56.             mars_boost::throw_exception(
  57.                     system::system_error(
  58.                             mars_boost::detail::winapi::GetLastError(),
  59.                             BOOST_CHRONO_SYSTEM_CATEGORY,
  60.                             "chrono::thread_clock" ));
  61.         }
  62.         else
  63.         {
  64.             ec.assign( mars_boost::detail::winapi::GetLastError(), BOOST_CHRONO_SYSTEM_CATEGORY );
  65.             return thread_clock::time_point(duration(0));
  66.         }
  67.     }
  68. }
  69. #endif
  70.  
  71. thread_clock::time_point thread_clock::now() BOOST_NOEXCEPT
  72. {
  73.  
  74.     //  note that Windows uses 100 nanosecond ticks for FILETIME
  75.     mars_boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
  76.  
  77.     if ( mars_boost::detail::winapi::GetThreadTimes(
  78.             mars_boost::detail::winapi::GetCurrentThread (), &creation, &exit,
  79.             &system_time, &user_time ) )
  80.     {
  81.         duration user   = duration(
  82.                 ((static_cast<duration::rep>(user_time.dwHighDateTime) << 32)
  83.                         | user_time.dwLowDateTime) * 100 );
  84.  
  85.         duration system = duration(
  86.                 ((static_cast<duration::rep>(system_time.dwHighDateTime) << 32)
  87.                         | system_time.dwLowDateTime) * 100 );
  88.  
  89.         return time_point(system+user);
  90.     }
  91.     else
  92.     {
  93.       BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
  94.       return time_point();
  95.     }
  96.  
  97. }
  98.  
  99. } // namespace chrono
  100. } // namespace mars_boost
  101.  
  102. #endif
  103.  
downloadthread_clock.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top