2 * Copyright Andrey Semashev 2007 - 2015.
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 #if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
22 #include <boost/detail/winapi/basic_types.hpp>
24 #include <boost/log/detail/header.hpp>
26 #ifdef BOOST_HAS_PRAGMA_ONCE
32 BOOST_LOG_OPEN_NAMESPACE
37 * Duration between two timestamps
44 explicit duration(int64_t ticks = 0) : m_ticks(ticks) {}
46 #if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
47 int64_t milliseconds() const { return m_ticks; }
49 BOOST_LOG_API int64_t milliseconds() const;
54 * Opaque timestamp class
61 explicit timestamp(uint64_t ticks = 0) : m_ticks(ticks) {}
63 duration operator- (timestamp that) const
65 return duration(m_ticks - that.m_ticks);
72 * The function returns a timestamp, in opaque units since an unspecified
73 * time point. This timer is guaranteed to be monotonic, it should not
74 * be affected by clock changes, either manual or seasonal. Also, it
75 * should be as fast as possible.
77 #if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
79 typedef uint64_t (WINAPI* get_tick_count_t)();
80 extern BOOST_LOG_API get_tick_count_t get_tick_count;
82 inline timestamp get_timestamp()
84 return timestamp(get_tick_count());
89 typedef timestamp (*get_timestamp_t)();
90 extern BOOST_LOG_API get_timestamp_t get_timestamp;
96 BOOST_LOG_CLOSE_NAMESPACE // namespace log
100 #include <boost/log/detail/footer.hpp>
102 #endif // BOOST_LOG_DETAIL_TIMESTAMP_HPP_INCLUDED_