Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:20

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   enqueued_record.hpp
0009  * \author Andrey Semashev
0010  * \date   01.04.2014
0011  *
0012  * \brief  This header is the Boost.Log library implementation, see the library documentation
0013  *         at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. In this file
0014  *         internal configuration macros are defined.
0015  */
0016 
0017 #ifndef BOOST_LOG_DETAIL_ENQUEUED_RECORD_HPP_INCLUDED_
0018 #define BOOST_LOG_DETAIL_ENQUEUED_RECORD_HPP_INCLUDED_
0019 
0020 #include <boost/move/core.hpp>
0021 #include <boost/move/utility_core.hpp>
0022 #include <boost/log/detail/config.hpp>
0023 #include <boost/log/detail/timestamp.hpp>
0024 #include <boost/log/core/record_view.hpp>
0025 #include <boost/log/detail/header.hpp>
0026 
0027 #ifdef BOOST_HAS_PRAGMA_ONCE
0028 #pragma once
0029 #endif
0030 
0031 namespace boost {
0032 
0033 BOOST_LOG_OPEN_NAMESPACE
0034 
0035 namespace sinks {
0036 
0037 namespace aux {
0038 
0039 //! Log record with enqueueing timestamp
0040 class enqueued_record
0041 {
0042     BOOST_COPYABLE_AND_MOVABLE(enqueued_record)
0043 
0044 public:
0045     //! Ordering predicate
0046     template< typename OrderT >
0047     struct order :
0048         public OrderT
0049     {
0050         typedef typename OrderT::result_type result_type;
0051 
0052         order() {}
0053         order(order const& that) : OrderT(static_cast< OrderT const& >(that)) {}
0054         order(OrderT const& that) : OrderT(that) {}
0055 
0056         result_type operator() (enqueued_record const& left, enqueued_record const& right) const
0057         {
0058             // std::priority_queue requires ordering with semantics of std::greater, so we swap arguments
0059             return OrderT::operator() (right.m_record, left.m_record);
0060         }
0061     };
0062 
0063     boost::log::aux::timestamp m_timestamp;
0064     record_view m_record;
0065 
0066     enqueued_record(enqueued_record const& that) BOOST_NOEXCEPT : m_timestamp(that.m_timestamp), m_record(that.m_record)
0067     {
0068     }
0069     enqueued_record(BOOST_RV_REF(enqueued_record) that) BOOST_NOEXCEPT :
0070         m_timestamp(that.m_timestamp),
0071         m_record(boost::move(that.m_record))
0072     {
0073     }
0074     explicit enqueued_record(record_view const& rec) :
0075         m_timestamp(boost::log::aux::get_timestamp()),
0076         m_record(rec)
0077     {
0078     }
0079     enqueued_record& operator= (BOOST_COPY_ASSIGN_REF(enqueued_record) that) BOOST_NOEXCEPT
0080     {
0081         m_timestamp = that.m_timestamp;
0082         m_record = that.m_record;
0083         return *this;
0084     }
0085     enqueued_record& operator= (BOOST_RV_REF(enqueued_record) that) BOOST_NOEXCEPT
0086     {
0087         m_timestamp = that.m_timestamp;
0088         m_record = boost::move(that.m_record);
0089         return *this;
0090     }
0091 };
0092 
0093 } // namespace aux
0094 
0095 } // namespace sinks
0096 
0097 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0098 
0099 } // namespace boost
0100 
0101 #include <boost/log/detail/footer.hpp>
0102 
0103 #endif // BOOST_LOG_DETAIL_ENQUEUED_RECORD_HPP_INCLUDED_