Back to home page

EIC code displayed by LXR

 
 

    


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

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   drop_on_overflow.hpp
0009  * \author Andrey Semashev
0010  * \date   04.01.2012
0011  *
0012  * The header contains implementation of \c drop_on_overflow strategy for handling
0013  * queue overflows in bounded queues for the asynchronous sink frontend.
0014  */
0015 
0016 #ifndef BOOST_LOG_SINKS_DROP_ON_OVERFLOW_HPP_INCLUDED_
0017 #define BOOST_LOG_SINKS_DROP_ON_OVERFLOW_HPP_INCLUDED_
0018 
0019 #include <boost/log/detail/config.hpp>
0020 #include <boost/log/core/record_view.hpp>
0021 #include <boost/log/detail/header.hpp>
0022 
0023 #ifdef BOOST_HAS_PRAGMA_ONCE
0024 #pragma once
0025 #endif
0026 
0027 namespace boost {
0028 
0029 BOOST_LOG_OPEN_NAMESPACE
0030 
0031 namespace sinks {
0032 
0033 /*!
0034  * \brief Log record dropping strategy
0035  *
0036  * This strategy will cause log records to be discarded in case of
0037  * queue overflow in bounded asynchronous sinks. It should not be used
0038  * if losing log records is not acceptable.
0039  */
0040 class drop_on_overflow
0041 {
0042 #ifndef BOOST_LOG_DOXYGEN_PASS
0043 public:
0044     /*!
0045      * This method is called by the queue when overflow is detected.
0046      *
0047      * \retval true Attempt to enqueue the record again.
0048      * \retval false Discard the record.
0049      */
0050     template< typename LockT >
0051     static bool on_overflow(record_view const&, LockT&)
0052     {
0053         return false;
0054     }
0055 
0056     /*!
0057      * This method is called by the queue when there appears a free space.
0058      */
0059     static void on_queue_space_available()
0060     {
0061     }
0062 
0063     /*!
0064      * This method is called by the queue to interrupt any possible waits in \c on_overflow.
0065      */
0066     static void interrupt()
0067     {
0068     }
0069 #endif // BOOST_LOG_DOXYGEN_PASS
0070 };
0071 
0072 } // namespace sinks
0073 
0074 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0075 
0076 } // namespace boost
0077 
0078 #include <boost/log/detail/footer.hpp>
0079 
0080 #endif // BOOST_LOG_SINKS_DROP_ON_OVERFLOW_HPP_INCLUDED_