Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file timer.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 02.12.2007 Chris@16: * Chris@16: * The header contains implementation of a stop watch attribute. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_ATTRIBUTES_TIMER_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_ATTRIBUTES_TIMER_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: namespace attributes { Chris@16: Chris@16: /*! Chris@16: * \brief A class of an attribute that makes an attribute value of the time interval since construction Chris@16: * Chris@16: * The timer attribute calculates the time passed since its construction and returns it on value acquisition. Chris@16: * The attribute value type is boost::posix_time::time_duration. Chris@16: * Chris@16: * On Windows platform there are two implementations of the attribute. The default one is more precise but Chris@16: * a bit slower. This version uses QueryPerformanceFrequence/QueryPerformanceCounter API Chris@16: * to calculate elapsed time. Chris@16: * Chris@16: * There are known problems with these functions when used with some CPUs, notably AMD Athlon with Chris@16: * Cool'n'Quiet technology enabled. See the following links for more information and possible resolutions: Chris@16: * Chris@16: * http://support.microsoft.com/?scid=kb;en-us;895980 Chris@16: * http://support.microsoft.com/?id=896256 Chris@16: * Chris@16: * In case if none of these solutions apply, you are free to define BOOST_LOG_NO_QUERY_PERFORMANCE_COUNTER macro to Chris@16: * fall back to another implementation based on Boost.DateTime. Chris@16: */ Chris@16: class BOOST_LOG_API timer : Chris@16: public attribute Chris@16: { Chris@16: public: Chris@16: //! Attribute value type Chris@16: typedef utc_time_traits::time_type::time_duration_type value_type; Chris@16: Chris@16: private: Chris@16: //! Factory implementation Chris@16: class BOOST_SYMBOL_VISIBLE impl; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Constructor. Starts time counting. Chris@16: */ Chris@16: timer(); Chris@16: /*! Chris@16: * Constructor for casting support Chris@16: */ Chris@16: explicit timer(cast_source const& source); Chris@16: }; Chris@16: Chris@16: } // namespace attributes Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_ATTRIBUTES_TIMER_HPP_INCLUDED_