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 drop_on_overflow.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 04.01.2012
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains implementation of \c drop_on_overflow strategy for handling
|
Chris@16
|
13 * queue overflows in bounded queues for the asynchronous sink frontend.
|
Chris@16
|
14 */
|
Chris@16
|
15
|
Chris@16
|
16 #ifndef BOOST_LOG_SINKS_DROP_ON_OVERFLOW_HPP_INCLUDED_
|
Chris@16
|
17 #define BOOST_LOG_SINKS_DROP_ON_OVERFLOW_HPP_INCLUDED_
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/log/detail/config.hpp>
|
Chris@16
|
20 #include <boost/log/core/record_view.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 sinks {
|
Chris@16
|
32
|
Chris@16
|
33 /*!
|
Chris@16
|
34 * \brief Log record dropping strategy
|
Chris@16
|
35 *
|
Chris@16
|
36 * This strategy will cause log records to be discarded in case of
|
Chris@16
|
37 * queue overflow in bounded asynchronous sinks. It should not be used
|
Chris@16
|
38 * if losing log records is not acceptable.
|
Chris@16
|
39 */
|
Chris@16
|
40 class drop_on_overflow
|
Chris@16
|
41 {
|
Chris@16
|
42 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
43 public:
|
Chris@16
|
44 /*!
|
Chris@16
|
45 * This method is called by the queue when overflow is detected.
|
Chris@16
|
46 *
|
Chris@16
|
47 * \retval true Attempt to enqueue the record again.
|
Chris@16
|
48 * \retval false Discard the record.
|
Chris@16
|
49 */
|
Chris@16
|
50 template< typename LockT >
|
Chris@16
|
51 static bool on_overflow(record_view const&, LockT&)
|
Chris@16
|
52 {
|
Chris@16
|
53 return false;
|
Chris@16
|
54 }
|
Chris@16
|
55
|
Chris@16
|
56 /*!
|
Chris@16
|
57 * This method is called by the queue when there appears a free space.
|
Chris@16
|
58 */
|
Chris@16
|
59 static void on_queue_space_available()
|
Chris@16
|
60 {
|
Chris@16
|
61 }
|
Chris@16
|
62
|
Chris@16
|
63 /*!
|
Chris@16
|
64 * This method is called by the queue to interrupt any possible waits in \c on_overflow.
|
Chris@16
|
65 */
|
Chris@16
|
66 static void interrupt()
|
Chris@16
|
67 {
|
Chris@16
|
68 }
|
Chris@16
|
69 #endif // BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
70 };
|
Chris@16
|
71
|
Chris@16
|
72 } // namespace sinks
|
Chris@16
|
73
|
Chris@16
|
74 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
75
|
Chris@16
|
76 } // namespace boost
|
Chris@16
|
77
|
Chris@16
|
78 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
79
|
Chris@16
|
80 #endif // BOOST_LOG_SINKS_DROP_ON_OVERFLOW_HPP_INCLUDED_
|