File indexing completed on 2026-08-17 08:38:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_INLINE_EXECUTOR_HPP
0012 #define BOOST_ASIO_INLINE_EXECUTOR_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/non_const_lvalue.hpp>
0020 #include <boost/asio/detail/type_traits.hpp>
0021 #include <boost/asio/execution.hpp>
0022
0023 #include <boost/asio/detail/push_options.hpp>
0024
0025 namespace boost {
0026 namespace asio {
0027
0028
0029 template <typename InlineExceptionHandling>
0030 class basic_inline_executor
0031 {
0032 public:
0033
0034 basic_inline_executor() noexcept
0035 {
0036 }
0037
0038 #if !defined(GENERATING_DOCUMENTATION)
0039 private:
0040 friend struct boost_asio_require_fn::impl;
0041 friend struct boost_asio_prefer_fn::impl;
0042 #endif
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 basic_inline_executor<execution::inline_exception_handling_t::propagate_t>
0056 require(execution::inline_exception_handling_t::propagate_t) const noexcept
0057 {
0058 return basic_inline_executor<
0059 execution::inline_exception_handling_t::propagate_t>();
0060 }
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 basic_inline_executor<execution::inline_exception_handling_t::terminate_t>
0074 require(execution::inline_exception_handling_t::terminate_t) const noexcept
0075 {
0076 return basic_inline_executor<
0077 execution::inline_exception_handling_t::terminate_t>();
0078 }
0079
0080 #if !defined(GENERATING_DOCUMENTATION)
0081 private:
0082 friend struct boost_asio_query_fn::impl;
0083 friend struct boost::asio::execution::detail::blocking_t<0>;
0084 friend struct boost::asio::execution::detail::mapping_t<0>;
0085 friend struct boost::asio::execution::detail::inline_exception_handling_t<0>;
0086 #endif
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 static constexpr execution::mapping_t query(
0100 execution::mapping_t) noexcept
0101 {
0102 return execution::mapping.thread;
0103 }
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117 static constexpr execution::inline_exception_handling_t query(
0118 execution::inline_exception_handling_t) noexcept
0119 {
0120 return InlineExceptionHandling();
0121 }
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 static constexpr execution::blocking_t query(
0135 execution::blocking_t) noexcept
0136 {
0137 return execution::blocking.always;
0138 }
0139
0140 public:
0141
0142
0143
0144
0145 friend bool operator==(const basic_inline_executor&,
0146 const basic_inline_executor&) noexcept
0147 {
0148 return true;
0149 }
0150
0151
0152
0153
0154
0155 friend bool operator!=(const basic_inline_executor&,
0156 const basic_inline_executor&) noexcept
0157 {
0158 return false;
0159 }
0160
0161
0162 template <typename Function>
0163 void execute(Function&& f) const
0164 {
0165 #if !defined(BOOST_ASIO_NO_EXCEPTIONS)
0166 try
0167 #endif
0168 {
0169 detail::non_const_lvalue<Function> f2(f);
0170 static_cast<decay_t<Function>&&>(f2.value)();
0171 }
0172 #if !defined(BOOST_ASIO_NO_EXCEPTIONS)
0173 catch (...)
0174 {
0175 if (is_same<InlineExceptionHandling,
0176 execution::inline_exception_handling_t::terminate_t>::value)
0177 {
0178 std::terminate();
0179 }
0180 else
0181 {
0182 throw;
0183 }
0184 }
0185 #endif
0186 }
0187 };
0188
0189
0190 typedef basic_inline_executor<
0191 execution::inline_exception_handling_t::propagate_t>
0192 inline_executor;
0193
0194 #if !defined(GENERATING_DOCUMENTATION)
0195
0196 namespace traits {
0197
0198 #if !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
0199
0200 template <typename InlineExceptionHandling>
0201 struct equality_comparable<
0202 basic_inline_executor<InlineExceptionHandling>
0203 >
0204 {
0205 static constexpr bool is_valid = true;
0206 static constexpr bool is_noexcept = true;
0207 };
0208
0209 #endif
0210
0211 #if !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
0212
0213 template <typename InlineExceptionHandling, typename Function>
0214 struct execute_member<
0215 basic_inline_executor<InlineExceptionHandling>,
0216 Function
0217 >
0218 {
0219 static constexpr bool is_valid = true;
0220 static constexpr bool is_noexcept = false;
0221 typedef void result_type;
0222 };
0223
0224 #endif
0225
0226 #if !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
0227
0228 template <typename InlineExceptionHandling>
0229 struct require_member<
0230 basic_inline_executor<InlineExceptionHandling>,
0231 execution::inline_exception_handling_t::propagate_t
0232 >
0233 {
0234 static constexpr bool is_valid = true;
0235 static constexpr bool is_noexcept = true;
0236 typedef basic_inline_executor<
0237 execution::inline_exception_handling_t::propagate_t>
0238 result_type;
0239 };
0240
0241 template <typename InlineExceptionHandling>
0242 struct require_member<
0243 basic_inline_executor<InlineExceptionHandling>,
0244 execution::inline_exception_handling_t::terminate_t
0245 >
0246 {
0247 static constexpr bool is_valid = true;
0248 static constexpr bool is_noexcept = true;
0249 typedef basic_inline_executor<
0250 execution::inline_exception_handling_t::terminate_t>
0251 result_type;
0252 };
0253
0254 #endif
0255
0256 #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
0257
0258 template <typename InlineExceptionHandling, typename Property>
0259 struct query_static_constexpr_member<
0260 basic_inline_executor<InlineExceptionHandling>,
0261 Property,
0262 enable_if_t<
0263 is_convertible<
0264 Property,
0265 execution::mapping_t
0266 >::value
0267 >
0268 >
0269 {
0270 static constexpr bool is_valid = true;
0271 static constexpr bool is_noexcept = true;
0272 typedef execution::mapping_t::thread_t result_type;
0273
0274 static constexpr result_type value() noexcept
0275 {
0276 return result_type();
0277 }
0278 };
0279
0280 template <typename InlineExceptionHandling, typename Property>
0281 struct query_static_constexpr_member<
0282 basic_inline_executor<InlineExceptionHandling>,
0283 Property,
0284 enable_if_t<
0285 is_convertible<
0286 Property,
0287 execution::inline_exception_handling_t
0288 >::value
0289 >
0290 >
0291 {
0292 static constexpr bool is_valid = true;
0293 static constexpr bool is_noexcept = true;
0294 typedef InlineExceptionHandling result_type;
0295
0296 static constexpr result_type value() noexcept
0297 {
0298 return result_type();
0299 }
0300 };
0301
0302 template <typename InlineExceptionHandling, typename Property>
0303 struct query_static_constexpr_member<
0304 basic_inline_executor<InlineExceptionHandling>,
0305 Property,
0306 enable_if_t<
0307 is_convertible<
0308 Property,
0309 execution::blocking_t
0310 >::value
0311 >
0312 >
0313 {
0314 static constexpr bool is_valid = true;
0315 static constexpr bool is_noexcept = true;
0316 typedef execution::blocking_t::always_t result_type;
0317
0318 static constexpr result_type value() noexcept
0319 {
0320 return result_type();
0321 }
0322 };
0323
0324 #endif
0325
0326 }
0327
0328 #endif
0329
0330 }
0331 }
0332
0333 #include <boost/asio/detail/pop_options.hpp>
0334
0335 #endif