2 * Copyright Andrey Semashev 2007 - 2014.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
9 * \author Andrey Semashev
12 * \brief This header is the Boost.Log library implementation, see the library documentation
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
16 #ifndef BOOST_LOG_DETAIL_TIMESTAMP_HPP_INCLUDED_
17 #define BOOST_LOG_DETAIL_TIMESTAMP_HPP_INCLUDED_
19 #include <boost/cstdint.hpp>
20 #include <boost/log/detail/config.hpp>
21 #include <boost/log/detail/header.hpp>
23 #ifdef BOOST_HAS_PRAGMA_ONCE
29 BOOST_LOG_OPEN_NAMESPACE
34 * Duration between two timestamps
41 explicit duration(int64_t ticks = 0) : m_ticks(ticks) {}
43 #if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
44 int64_t milliseconds() const { return m_ticks; }
46 BOOST_LOG_API int64_t milliseconds() const;
51 * Opaque timestamp class
58 explicit timestamp(uint64_t ticks = 0) : m_ticks(ticks) {}
60 duration operator- (timestamp that) const
62 return duration(m_ticks - that.m_ticks);
69 * The function returns a timestamp, in opaque units since an unspecified
70 * time point. This timer is guaranteed to be monotonic, it should not
71 * be affected by clock changes, either manual or seasonal. Also, it
72 * should be as fast as possible.
74 #if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
76 typedef uint64_t (__stdcall* get_tick_count_t)();
77 extern BOOST_LOG_API get_tick_count_t get_tick_count;
79 inline timestamp get_timestamp()
81 return timestamp(get_tick_count());
86 typedef timestamp (*get_timestamp_t)();
87 extern BOOST_LOG_API get_timestamp_t get_timestamp;
93 BOOST_LOG_CLOSE_NAMESPACE // namespace log
97 #include <boost/log/detail/footer.hpp>
99 #endif // BOOST_LOG_DETAIL_TIMESTAMP_HPP_INCLUDED_