annotate DEPENDENCIES/generic/include/boost/log/detail/timestamp.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@101 2 * Copyright Andrey Semashev 2007 - 2015.
Chris@16 3 * Distributed under the Boost Software License, Version 1.0.
Chris@16 4 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7 /*!
Chris@16 8 * \file timestamp.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 31.07.2011
Chris@16 11 *
Chris@16 12 * \brief This header is the Boost.Log library implementation, see the library documentation
Chris@16 13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
Chris@16 14 */
Chris@16 15
Chris@16 16 #ifndef BOOST_LOG_DETAIL_TIMESTAMP_HPP_INCLUDED_
Chris@16 17 #define BOOST_LOG_DETAIL_TIMESTAMP_HPP_INCLUDED_
Chris@16 18
Chris@16 19 #include <boost/cstdint.hpp>
Chris@16 20 #include <boost/log/detail/config.hpp>
Chris@16 21 #include <boost/log/detail/header.hpp>
Chris@16 22
Chris@16 23 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 24 #pragma once
Chris@16 25 #endif
Chris@16 26
Chris@16 27 namespace boost {
Chris@16 28
Chris@16 29 BOOST_LOG_OPEN_NAMESPACE
Chris@16 30
Chris@16 31 namespace aux {
Chris@16 32
Chris@16 33 /*!
Chris@16 34 * Duration between two timestamps
Chris@16 35 */
Chris@16 36 class duration
Chris@16 37 {
Chris@16 38 int64_t m_ticks;
Chris@16 39
Chris@16 40 public:
Chris@16 41 explicit duration(int64_t ticks = 0) : m_ticks(ticks) {}
Chris@16 42
Chris@16 43 #if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
Chris@16 44 int64_t milliseconds() const { return m_ticks; }
Chris@16 45 #else
Chris@16 46 BOOST_LOG_API int64_t milliseconds() const;
Chris@16 47 #endif
Chris@16 48 };
Chris@16 49
Chris@16 50 /*!
Chris@16 51 * Opaque timestamp class
Chris@16 52 */
Chris@16 53 class timestamp
Chris@16 54 {
Chris@16 55 uint64_t m_ticks;
Chris@16 56
Chris@16 57 public:
Chris@16 58 explicit timestamp(uint64_t ticks = 0) : m_ticks(ticks) {}
Chris@16 59
Chris@16 60 duration operator- (timestamp that) const
Chris@16 61 {
Chris@16 62 return duration(m_ticks - that.m_ticks);
Chris@16 63 }
Chris@16 64 };
Chris@16 65
Chris@16 66 /*!
Chris@16 67 * \fn get_timestamp
Chris@16 68 *
Chris@16 69 * The function returns a timestamp, in opaque units since an unspecified
Chris@16 70 * time point. This timer is guaranteed to be monotonic, it should not
Chris@16 71 * be affected by clock changes, either manual or seasonal. Also, it
Chris@16 72 * should be as fast as possible.
Chris@16 73 */
Chris@16 74 #if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
Chris@16 75
Chris@16 76 typedef uint64_t (__stdcall* get_tick_count_t)();
Chris@16 77 extern BOOST_LOG_API get_tick_count_t get_tick_count;
Chris@16 78
Chris@16 79 inline timestamp get_timestamp()
Chris@16 80 {
Chris@16 81 return timestamp(get_tick_count());
Chris@16 82 }
Chris@16 83
Chris@16 84 #else
Chris@16 85
Chris@16 86 typedef timestamp (*get_timestamp_t)();
Chris@16 87 extern BOOST_LOG_API get_timestamp_t get_timestamp;
Chris@16 88
Chris@16 89 #endif
Chris@16 90
Chris@16 91 } // namespace aux
Chris@16 92
Chris@16 93 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 94
Chris@16 95 } // namespace boost
Chris@16 96
Chris@16 97 #include <boost/log/detail/footer.hpp>
Chris@16 98
Chris@16 99 #endif // BOOST_LOG_DETAIL_TIMESTAMP_HPP_INCLUDED_