Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/log/sinks/unbounded_ordering_queue.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 /* | 1 /* |
2 * Copyright Andrey Semashev 2007 - 2013. | 2 * Copyright Andrey Semashev 2007 - 2015. |
3 * Distributed under the Boost Software License, Version 1.0. | 3 * Distributed under the Boost Software License, Version 1.0. |
4 * (See accompanying file LICENSE_1_0.txt or copy at | 4 * (See accompanying file LICENSE_1_0.txt or copy at |
5 * http://www.boost.org/LICENSE_1_0.txt) | 5 * http://www.boost.org/LICENSE_1_0.txt) |
6 */ | 6 */ |
7 /*! | 7 /*! |
27 #endif | 27 #endif |
28 | 28 |
29 #include <queue> | 29 #include <queue> |
30 #include <vector> | 30 #include <vector> |
31 #include <boost/cstdint.hpp> | 31 #include <boost/cstdint.hpp> |
32 #include <boost/move/core.hpp> | |
33 #include <boost/move/utility.hpp> | |
34 #include <boost/thread/locks.hpp> | 32 #include <boost/thread/locks.hpp> |
35 #include <boost/thread/mutex.hpp> | 33 #include <boost/thread/mutex.hpp> |
36 #include <boost/thread/condition_variable.hpp> | 34 #include <boost/thread/condition_variable.hpp> |
37 #include <boost/thread/thread_time.hpp> | 35 #include <boost/thread/thread_time.hpp> |
38 #include <boost/date_time/posix_time/posix_time_types.hpp> | 36 #include <boost/date_time/posix_time/posix_time_types.hpp> |
39 #include <boost/log/detail/timestamp.hpp> | 37 #include <boost/log/detail/timestamp.hpp> |
38 #include <boost/log/detail/enqueued_record.hpp> | |
40 #include <boost/log/keywords/order.hpp> | 39 #include <boost/log/keywords/order.hpp> |
41 #include <boost/log/keywords/ordering_window.hpp> | 40 #include <boost/log/keywords/ordering_window.hpp> |
42 #include <boost/log/core/record_view.hpp> | 41 #include <boost/log/core/record_view.hpp> |
43 #include <boost/log/detail/header.hpp> | 42 #include <boost/log/detail/header.hpp> |
44 | 43 |
69 template< typename OrderT > | 68 template< typename OrderT > |
70 class unbounded_ordering_queue | 69 class unbounded_ordering_queue |
71 { | 70 { |
72 private: | 71 private: |
73 typedef boost::mutex mutex_type; | 72 typedef boost::mutex mutex_type; |
74 | 73 typedef sinks::aux::enqueued_record enqueued_record; |
75 //! Log record with enqueueing timestamp | |
76 class enqueued_record | |
77 { | |
78 BOOST_COPYABLE_AND_MOVABLE(enqueued_record) | |
79 | |
80 public: | |
81 //! Ordering predicate | |
82 struct order : | |
83 public OrderT | |
84 { | |
85 typedef typename OrderT::result_type result_type; | |
86 | |
87 order() {} | |
88 order(order const& that) : OrderT(static_cast< OrderT const& >(that)) {} | |
89 order(OrderT const& that) : OrderT(that) {} | |
90 | |
91 result_type operator() (enqueued_record const& left, enqueued_record const& right) const | |
92 { | |
93 // std::priority_queue requires ordering with semantics of std::greater, so we swap arguments | |
94 return OrderT::operator() (right.m_record, left.m_record); | |
95 } | |
96 }; | |
97 | |
98 boost::log::aux::timestamp m_timestamp; | |
99 record_view m_record; | |
100 | |
101 enqueued_record(enqueued_record const& that) : m_timestamp(that.m_timestamp), m_record(that.m_record) | |
102 { | |
103 } | |
104 enqueued_record(BOOST_RV_REF(enqueued_record) that) : | |
105 m_timestamp(that.m_timestamp), | |
106 m_record(boost::move(that.m_record)) | |
107 { | |
108 } | |
109 explicit enqueued_record(record_view const& rec) : | |
110 m_timestamp(boost::log::aux::get_timestamp()), | |
111 m_record(rec) | |
112 { | |
113 } | |
114 enqueued_record& operator= (BOOST_COPY_ASSIGN_REF(enqueued_record) that) | |
115 { | |
116 m_timestamp = that.m_timestamp; | |
117 m_record = that.m_record; | |
118 return *this; | |
119 } | |
120 enqueued_record& operator= (BOOST_RV_REF(enqueued_record) that) | |
121 { | |
122 m_timestamp = that.m_timestamp; | |
123 m_record = boost::move(that.m_record); | |
124 return *this; | |
125 } | |
126 }; | |
127 | 74 |
128 typedef std::priority_queue< | 75 typedef std::priority_queue< |
129 enqueued_record, | 76 enqueued_record, |
130 std::vector< enqueued_record >, | 77 std::vector< enqueued_record >, |
131 typename enqueued_record::order | 78 enqueued_record::order< OrderT > |
132 > queue_type; | 79 > queue_type; |
133 | 80 |
134 private: | 81 private: |
135 //! Ordering window duration, in milliseconds | 82 //! Ordering window duration, in milliseconds |
136 const uint64_t m_ordering_window; | 83 const uint64_t m_ordering_window; |