File indexing completed on 2025-04-26 08:25:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_IMMEDIATE_HPP
0012 #define BOOST_ASIO_IMMEDIATE_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/associated_immediate_executor.hpp>
0020 #include <boost/asio/async_result.hpp>
0021 #include <boost/asio/dispatch.hpp>
0022
0023 #include <boost/asio/detail/push_options.hpp>
0024
0025 namespace boost {
0026 namespace asio {
0027 namespace detail {
0028
0029 template <typename Executor>
0030 class initiate_immediate
0031 {
0032 public:
0033 typedef Executor executor_type;
0034
0035 explicit initiate_immediate(const Executor& ex)
0036 : ex_(ex)
0037 {
0038 }
0039
0040 executor_type get_executor() const noexcept
0041 {
0042 return ex_;
0043 }
0044
0045 template <typename CompletionHandler>
0046 void operator()(CompletionHandler&& handler) const
0047 {
0048 typename associated_immediate_executor<
0049 CompletionHandler, executor_type>::type ex =
0050 (get_associated_immediate_executor)(handler, ex_);
0051 (dispatch)(ex, static_cast<CompletionHandler&&>(handler));
0052 }
0053
0054 private:
0055 Executor ex_;
0056 };
0057
0058 }
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 template <typename Executor,
0081 BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken
0082 = default_completion_token_t<Executor>>
0083 inline auto async_immediate(const Executor& ex,
0084 NullaryToken&& token = default_completion_token_t<Executor>(),
0085 constraint_t<
0086 (execution::is_executor<Executor>::value
0087 && can_require<Executor, execution::blocking_t::never_t>::value)
0088 || is_executor<Executor>::value
0089 > = 0)
0090 -> decltype(
0091 async_initiate<NullaryToken, void()>(
0092 declval<detail::initiate_immediate<Executor>>(), token))
0093 {
0094 return async_initiate<NullaryToken, void()>(
0095 detail::initiate_immediate<Executor>(ex), token);
0096 }
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 template <typename ExecutionContext,
0120 BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken
0121 = default_completion_token_t<typename ExecutionContext::executor_type>>
0122 inline auto async_immediate(ExecutionContext& ctx,
0123 NullaryToken&& token = default_completion_token_t<
0124 typename ExecutionContext::executor_type>(),
0125 constraint_t<
0126 is_convertible<ExecutionContext&, execution_context&>::value
0127 > = 0)
0128 -> decltype(
0129 async_initiate<NullaryToken, void()>(
0130 declval<detail::initiate_immediate<
0131 typename ExecutionContext::executor_type>>(), token))
0132 {
0133 return async_initiate<NullaryToken, void()>(
0134 detail::initiate_immediate<
0135 typename ExecutionContext::executor_type>(
0136 ctx.get_executor()), token);
0137 }
0138
0139 }
0140 }
0141
0142 #include <boost/asio/detail/pop_options.hpp>
0143
0144 #endif