Blame view

3rdparty/boost_1_81_0/boost/log/attributes/timer.hpp 2.41 KB
63e88f80   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  /*
   *          Copyright Andrey Semashev 2007 - 2015.
   * Distributed under the Boost Software License, Version 1.0.
   *    (See accompanying file LICENSE_1_0.txt or copy at
   *          http://www.boost.org/LICENSE_1_0.txt)
   */
  /*!
   * \file   timer.hpp
   * \author Andrey Semashev
   * \date   02.12.2007
   *
   * The header contains implementation of a stop watch attribute.
   */
  
  #ifndef BOOST_LOG_ATTRIBUTES_TIMER_HPP_INCLUDED_
  #define BOOST_LOG_ATTRIBUTES_TIMER_HPP_INCLUDED_
  
  #include <boost/log/detail/config.hpp>
  #include <boost/log/attributes/attribute.hpp>
  #include <boost/log/attributes/attribute_cast.hpp>
  #include <boost/log/attributes/time_traits.hpp>
  #include <boost/log/detail/header.hpp>
  
  #ifdef BOOST_HAS_PRAGMA_ONCE
  #pragma once
  #endif
  
  namespace boost {
  
  BOOST_LOG_OPEN_NAMESPACE
  
  namespace attributes {
  
  /*!
   * \brief A class of an attribute that makes an attribute value of the time interval since construction
   *
   * The timer attribute calculates the time passed since its construction and returns it on value acquisition.
   * The attribute value type is <tt>boost::posix_time::time_duration</tt>.
   *
   * On Windows platform there are two implementations of the attribute. The default one is more precise but
   * a bit slower. This version uses <tt>QueryPerformanceFrequence</tt>/<tt>QueryPerformanceCounter</tt> API
   * to calculate elapsed time.
   *
   * There are known problems with these functions when used with some CPUs, notably AMD Athlon with
   * Cool'n'Quiet technology enabled. See the following links for more information and possible resolutions:
   *
   * http://support.microsoft.com/?scid=kb;en-us;895980
   * http://support.microsoft.com/?id=896256
   *
   * In case if none of these solutions apply, you are free to define <tt>BOOST_LOG_NO_QUERY_PERFORMANCE_COUNTER</tt> macro to
   * fall back to another implementation based on Boost.DateTime.
   */
  class BOOST_LOG_API timer :
      public attribute
  {
  public:
      //! Attribute value type
      typedef utc_time_traits::time_type::time_duration_type value_type;
  
  private:
      //! Factory implementation
      class BOOST_SYMBOL_VISIBLE impl;
  
  public:
      /*!
       * Constructor. Starts time counting.
       */
      timer();
      /*!
       * Constructor for casting support
       */
      explicit timer(cast_source const& source);
  };
  
  } // namespace attributes
  
  BOOST_LOG_CLOSE_NAMESPACE // namespace log
  
  } // namespace boost
  
  #include <boost/log/detail/footer.hpp>
  
  #endif // BOOST_LOG_ATTRIBUTES_TIMER_HPP_INCLUDED_