File indexing completed on 2025-01-18 09:39:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_SINKS_UNLOCKED_FRONTEND_HPP_INCLUDED_
0016 #define BOOST_LOG_SINKS_UNLOCKED_FRONTEND_HPP_INCLUDED_
0017
0018 #include <boost/smart_ptr/shared_ptr.hpp>
0019 #include <boost/smart_ptr/make_shared_object.hpp>
0020 #include <boost/preprocessor/control/if.hpp>
0021 #include <boost/preprocessor/comparison/equal.hpp>
0022 #include <boost/log/detail/config.hpp>
0023 #include <boost/log/detail/parameter_tools.hpp>
0024 #include <boost/log/detail/fake_mutex.hpp>
0025 #include <boost/log/sinks/basic_sink_frontend.hpp>
0026 #include <boost/log/sinks/frontend_requirements.hpp>
0027 #include <boost/log/detail/header.hpp>
0028
0029 #ifdef BOOST_HAS_PRAGMA_ONCE
0030 #pragma once
0031 #endif
0032
0033 namespace boost {
0034
0035 BOOST_LOG_OPEN_NAMESPACE
0036
0037 namespace sinks {
0038
0039 #ifndef BOOST_LOG_DOXYGEN_PASS
0040
0041 #define BOOST_LOG_SINK_CTOR_FORWARD_INTERNAL_1(z, n, data)\
0042 template< typename T0 >\
0043 explicit unlocked_sink(T0 const& arg0, typename boost::log::aux::enable_if_named_parameters< T0, boost::log::aux::sfinae_dummy >::type = boost::log::aux::sfinae_dummy()) :\
0044 base_type(false),\
0045 m_pBackend(boost::make_shared< sink_backend_type >(arg0)) {}
0046
0047 #define BOOST_LOG_SINK_CTOR_FORWARD_INTERNAL_N(z, n, data)\
0048 template< BOOST_PP_ENUM_PARAMS_Z(z, n, typename T) >\
0049 explicit unlocked_sink(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, T, const& arg)) :\
0050 base_type(false),\
0051 m_pBackend(boost::make_shared< sink_backend_type >(BOOST_PP_ENUM_PARAMS_Z(z, n, arg))) {}
0052
0053 #define BOOST_LOG_SINK_CTOR_FORWARD_INTERNAL(z, n, data)\
0054 BOOST_PP_IF(BOOST_PP_EQUAL(n, 1), BOOST_LOG_SINK_CTOR_FORWARD_INTERNAL_1, BOOST_LOG_SINK_CTOR_FORWARD_INTERNAL_N)(z, n, data)
0055
0056 #endif
0057
0058
0059
0060
0061
0062
0063
0064 template< typename SinkBackendT >
0065 class unlocked_sink :
0066 public aux::make_sink_frontend_base< SinkBackendT >::type
0067 {
0068 typedef typename aux::make_sink_frontend_base< SinkBackendT >::type base_type;
0069
0070 public:
0071
0072 typedef SinkBackendT sink_backend_type;
0073
0074 static_assert(has_requirement< typename sink_backend_type::frontend_requirements, concurrent_feeding >::value, "Unlocked sink frontend is incompatible with the specified backend: thread synchronization requirements are not met");
0075
0076
0077
0078 typedef shared_ptr< sink_backend_type > locked_backend_ptr;
0079
0080 private:
0081
0082 const shared_ptr< sink_backend_type > m_pBackend;
0083
0084 public:
0085
0086
0087
0088
0089 unlocked_sink() :
0090 base_type(false),
0091 m_pBackend(boost::make_shared< sink_backend_type >())
0092 {
0093 }
0094
0095
0096
0097
0098
0099
0100
0101 explicit unlocked_sink(shared_ptr< sink_backend_type > const& backend) :
0102 base_type(false),
0103 m_pBackend(backend)
0104 {
0105 }
0106
0107
0108
0109
0110
0111 #ifndef BOOST_LOG_DOXYGEN_PASS
0112 BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_SINK_CTOR_FORWARD_INTERNAL, ~)
0113 #else
0114 template< typename... Args >
0115 explicit unlocked_sink(Args&&... args);
0116 #endif
0117
0118
0119
0120
0121
0122
0123
0124 locked_backend_ptr locked_backend()
0125 {
0126 return m_pBackend;
0127 }
0128
0129
0130
0131
0132 void consume(record_view const& rec)
0133 {
0134 boost::log::aux::fake_mutex m;
0135 base_type::feed_record(rec, m, *m_pBackend);
0136 }
0137
0138
0139
0140
0141
0142
0143 void flush()
0144 {
0145 boost::log::aux::fake_mutex m;
0146 base_type::flush_backend(m, *m_pBackend);
0147 }
0148 };
0149
0150 #undef BOOST_LOG_SINK_CTOR_FORWARD_INTERNAL_1
0151 #undef BOOST_LOG_SINK_CTOR_FORWARD_INTERNAL_N
0152 #undef BOOST_LOG_SINK_CTOR_FORWARD_INTERNAL
0153
0154 }
0155
0156 BOOST_LOG_CLOSE_NAMESPACE
0157
0158 }
0159
0160 #include <boost/log/detail/footer.hpp>
0161
0162 #endif