1 | // boost/chrono/thread_clock.hpp -----------------------------------------------------------// |
2 | |
3 | // Copyright 2009-2011 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/system for documentation. |
9 | |
10 | #include <boost/chrono/config.hpp> |
11 | |
12 | #ifndef BOOST_CHRONO_THREAD_CLOCK_HPP |
13 | #define BOOST_CHRONO_THREAD_CLOCK_HPP |
14 | |
15 | #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK) |
16 | |
17 | #include <boost/chrono/config.hpp> |
18 | #include <boost/chrono/duration.hpp> |
19 | #include <boost/chrono/time_point.hpp> |
20 | #include <boost/chrono/detail/system.hpp> |
21 | #include <boost/chrono/clock_string.hpp> |
22 | |
23 | #ifndef BOOST_CHRONO_HEADER_ONLY |
24 | #include <boost/config/abi_prefix.hpp> // must be the last #include |
25 | #endif |
26 | |
27 | namespace boost { namespace chrono { |
28 | |
29 | class BOOST_CHRONO_DECL thread_clock { |
30 | public: |
31 | typedef nanoseconds duration; |
32 | typedef duration::rep rep; |
33 | typedef duration::period period; |
34 | typedef chrono::time_point<thread_clock> time_point; |
35 | BOOST_STATIC_CONSTEXPR bool is_steady = BOOST_CHRONO_THREAD_CLOCK_IS_STEADY; |
36 | |
37 | static BOOST_CHRONO_INLINE time_point now( ) BOOST_NOEXCEPT; |
38 | #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING |
39 | static BOOST_CHRONO_INLINE time_point now( system::error_code & ec ); |
40 | #endif |
41 | }; |
42 | |
43 | template <class CharT> |
44 | struct clock_string<thread_clock, CharT> |
45 | { |
46 | static std::basic_string<CharT> name() |
47 | { |
48 | static const CharT u[] = |
49 | { 't', 'h', 'r', 'e', 'a', 'd', '_', |
50 | 'c', 'l','o', 'c', 'k'}; |
51 | static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0])); |
52 | return str; |
53 | } |
54 | static std::basic_string<CharT> since() |
55 | { |
56 | const CharT u[] = |
57 | { ' ', 's', 'i', 'n', 'c', 'e', ' ', 't', 'h', 'r', 'e', 'a', 'd', ' ', 's', 't', 'a', 'r', 't', '-', 'u', 'p'}; |
58 | const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0])); |
59 | return str; |
60 | } |
61 | }; |
62 | |
63 | } // namespace chrono |
64 | } // namespace boost |
65 | |
66 | |
67 | #ifndef BOOST_CHRONO_HEADER_ONLY |
68 | #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas |
69 | #else |
70 | #include <boost/chrono/detail/inlined/thread_clock.hpp> |
71 | #endif |
72 | |
73 | #endif |
74 | |
75 | #endif // BOOST_CHRONO_THREAD_CLOCK_HPP |
76 | |