thread_clock.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // boost/chrono/thread_clock.hpp -----------------------------------------------------------//
  2. // Copyright 2009-2011 Vicente J. Botet Escriba
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. // See http://www.boost.org/libs/system for documentation.
  6. #include <boost/chrono/config.hpp>
  7. #ifndef BOOST_CHRONO_THREAD_CLOCK_HPP
  8. #define BOOST_CHRONO_THREAD_CLOCK_HPP
  9. #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
  10. #include <boost/chrono/config.hpp>
  11. #include <boost/chrono/duration.hpp>
  12. #include <boost/chrono/time_point.hpp>
  13. #include <boost/chrono/detail/system.hpp>
  14. #include <boost/chrono/clock_string.hpp>
  15. #ifndef BOOST_CHRONO_HEADER_ONLY
  16. #include <boost/config/abi_prefix.hpp> // must be the last #include
  17. #endif
  18. namespace boost { namespace chrono {
  19. class BOOST_CHRONO_DECL thread_clock {
  20. public:
  21. typedef nanoseconds duration;
  22. typedef duration::rep rep;
  23. typedef duration::period period;
  24. typedef chrono::time_point<thread_clock> time_point;
  25. BOOST_STATIC_CONSTEXPR bool is_steady = BOOST_CHRONO_THREAD_CLOCK_IS_STEADY;
  26. static BOOST_CHRONO_INLINE time_point now( ) BOOST_NOEXCEPT;
  27. #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
  28. static BOOST_CHRONO_INLINE time_point now( system::error_code & ec );
  29. #endif
  30. };
  31. template <class CharT>
  32. struct clock_string<thread_clock, CharT>
  33. {
  34. static std::basic_string<CharT> name()
  35. {
  36. static const CharT u[] =
  37. { 't', 'h', 'r', 'e', 'a', 'd', '_',
  38. 'c', 'l','o', 'c', 'k'};
  39. static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
  40. return str;
  41. }
  42. static std::basic_string<CharT> since()
  43. {
  44. const CharT u[] =
  45. { ' ', 's', 'i', 'n', 'c', 'e', ' ', 't', 'h', 'r', 'e', 'a', 'd', ' ', 's', 't', 'a', 'r', 't', '-', 'u', 'p'};
  46. const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
  47. return str;
  48. }
  49. };
  50. } // namespace chrono
  51. } // namespace boost
  52. #ifndef BOOST_CHRONO_HEADER_ONLY
  53. #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
  54. #else
  55. #include <boost/chrono/detail/inlined/thread_clock.hpp>
  56. #endif
  57. #endif
  58. #endif // BOOST_CHRONO_THREAD_CLOCK_HPP