File indexing completed on 2025-01-18 09:39:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BOOST_LOG_UTILITY_STRICTEST_LOCK_HPP_INCLUDED_
0017 #define BOOST_LOG_UTILITY_STRICTEST_LOCK_HPP_INCLUDED_
0018
0019 #include <boost/type_traits/integral_constant.hpp>
0020 #include <boost/log/detail/config.hpp>
0021 #include <boost/log/detail/locks.hpp>
0022 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0023 #include <boost/preprocessor/cat.hpp>
0024 #include <boost/preprocessor/arithmetic/sub.hpp>
0025 #include <boost/preprocessor/arithmetic/inc.hpp>
0026 #include <boost/preprocessor/arithmetic/dec.hpp>
0027 #include <boost/preprocessor/repetition/enum_trailing.hpp>
0028 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
0029 #include <boost/log/detail/pp_identity.hpp>
0030 #endif
0031 #if defined(BOOST_LOG_BROKEN_CONSTANT_EXPRESSIONS)
0032 #include <boost/mpl/less.hpp>
0033 #endif
0034 #include <boost/log/detail/header.hpp>
0035
0036 #ifdef BOOST_HAS_PRAGMA_ONCE
0037 #pragma once
0038 #endif
0039
0040 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0041 #if !defined(BOOST_LOG_STRICTEST_LOCK_LIMIT)
0042
0043
0044
0045
0046 #define BOOST_LOG_STRICTEST_LOCK_LIMIT 10
0047 #endif
0048 #if BOOST_LOG_STRICTEST_LOCK_LIMIT < 2
0049 #error The BOOST_LOG_STRICTEST_LOCK_LIMIT macro should not be less than 2
0050 #endif
0051 #endif
0052
0053 namespace boost {
0054
0055 BOOST_LOG_OPEN_NAMESPACE
0056
0057
0058 enum lock_access_mode
0059 {
0060 unlocked_access,
0061 shared_access,
0062 exclusive_access
0063 };
0064
0065
0066 template< typename LockT >
0067 struct thread_access_mode_of;
0068
0069 template< typename MutexT >
0070 struct thread_access_mode_of< no_lock< MutexT > > : boost::integral_constant< lock_access_mode, unlocked_access >
0071 {
0072 };
0073
0074 #if !defined(BOOST_LOG_NO_THREADS)
0075
0076 template< typename MutexT >
0077 struct thread_access_mode_of< lock_guard< MutexT > > : boost::integral_constant< lock_access_mode, exclusive_access >
0078 {
0079 };
0080
0081 template< typename MutexT >
0082 struct thread_access_mode_of< shared_lock_guard< MutexT > > : boost::integral_constant< lock_access_mode, shared_access >
0083 {
0084 };
0085
0086 template< typename MutexT >
0087 struct thread_access_mode_of< unique_lock< MutexT > > : boost::integral_constant< lock_access_mode, exclusive_access >
0088 {
0089 };
0090
0091 template< typename MutexT >
0092 struct thread_access_mode_of< shared_lock< MutexT > > : boost::integral_constant< lock_access_mode, shared_access >
0093 {
0094 };
0095
0096 template< typename MutexT >
0097 struct thread_access_mode_of< upgrade_lock< MutexT > > : boost::integral_constant< lock_access_mode, shared_access >
0098 {
0099 };
0100
0101 template< typename MutexT >
0102 struct thread_access_mode_of< boost::log::aux::exclusive_lock_guard< MutexT > > : boost::integral_constant< lock_access_mode, exclusive_access >
0103 {
0104 };
0105
0106 template< typename MutexT >
0107 struct thread_access_mode_of< boost::log::aux::shared_lock_guard< MutexT > > : boost::integral_constant< lock_access_mode, shared_access >
0108 {
0109 };
0110
0111 template< typename MutexT1, typename MutexT2 >
0112 struct thread_access_mode_of< boost::log::aux::multiple_unique_lock2< MutexT1, MutexT2 > > : boost::integral_constant< lock_access_mode, exclusive_access >
0113 {
0114 };
0115
0116 #endif
0117
0118 namespace aux {
0119
0120
0121 template<
0122 typename LeftLockT,
0123 typename RightLockT,
0124 #if !defined(BOOST_LOG_BROKEN_CONSTANT_EXPRESSIONS)
0125 bool CondV = (thread_access_mode_of< LeftLockT >::value < thread_access_mode_of< RightLockT >::value)
0126 #else
0127 bool CondV = mpl::less< thread_access_mode_of< LeftLockT >, thread_access_mode_of< RightLockT > >::value
0128 #endif
0129 >
0130 struct strictest_lock_impl
0131 {
0132 typedef RightLockT type;
0133 };
0134 template< typename LeftLockT, typename RightLockT >
0135 struct strictest_lock_impl< LeftLockT, RightLockT, false >
0136 {
0137 typedef LeftLockT type;
0138 };
0139
0140 }
0141
0142 #if defined(BOOST_LOG_DOXYGEN_PASS)
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153 template< typename... LocksT >
0154 struct strictest_lock
0155 {
0156 typedef implementation_defined type;
0157 };
0158
0159 #else
0160
0161 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0162
0163 template< typename LockT, typename... LocksT >
0164 struct strictest_lock;
0165
0166 template< typename LockT >
0167 struct strictest_lock< LockT >
0168 {
0169 typedef LockT type;
0170 };
0171
0172 template< typename LeftLockT, typename RightLockT >
0173 struct strictest_lock< LeftLockT, RightLockT >
0174 {
0175 typedef typename aux::strictest_lock_impl< LeftLockT, RightLockT >::type type;
0176 };
0177
0178 template< typename LeftLockT, typename RightLockT, typename... LocksT >
0179 struct strictest_lock< LeftLockT, RightLockT, LocksT... >
0180 {
0181 typedef typename strictest_lock<
0182 typename aux::strictest_lock_impl< LeftLockT, RightLockT >::type,
0183 LocksT...
0184 >::type type;
0185 };
0186
0187 #else
0188
0189 # define BOOST_LOG_TYPE_INTERNAL(z, i, data) BOOST_PP_CAT(T, BOOST_PP_INC(i))
0190
0191 template<
0192 typename T,
0193 BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_DEC(BOOST_LOG_STRICTEST_LOCK_LIMIT), typename T, void)
0194 >
0195 struct strictest_lock
0196 {
0197 typedef typename strictest_lock<
0198 typename boost::log::aux::strictest_lock_impl< T, T0 >::type
0199 BOOST_PP_ENUM_TRAILING(BOOST_PP_SUB(BOOST_LOG_STRICTEST_LOCK_LIMIT, 2), BOOST_LOG_TYPE_INTERNAL, ~)
0200 >::type type;
0201 };
0202
0203 template< typename T >
0204 struct strictest_lock<
0205 T
0206 BOOST_PP_ENUM_TRAILING(BOOST_PP_DEC(BOOST_LOG_STRICTEST_LOCK_LIMIT), BOOST_LOG_PP_IDENTITY, void)
0207 >
0208 {
0209 typedef T type;
0210 };
0211
0212 # undef BOOST_LOG_TYPE_INTERNAL
0213
0214 #endif
0215
0216 #endif
0217
0218 BOOST_LOG_CLOSE_NAMESPACE
0219
0220 }
0221
0222 #include <boost/log/detail/footer.hpp>
0223
0224 #endif