11 #ifndef ASIO_DETAIL_WRAPPED_HANDLER_HPP 12 #define ASIO_DETAIL_WRAPPED_HANDLER_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/bind_handler.hpp" 19 #include "asio/detail/handler_alloc_helpers.hpp" 20 #include "asio/detail/handler_cont_helpers.hpp" 21 #include "asio/detail/handler_invoke_helpers.hpp" 23 #include "asio/detail/push_options.hpp" 30 template <
typename Dispatcher,
typename Handler>
31 bool operator()(Dispatcher&, Handler& handler)
const 33 return asio_handler_cont_helpers::is_continuation(handler);
39 template <
typename Dispatcher,
typename Handler>
40 bool operator()(Dispatcher& dispatcher, Handler&)
const 42 return dispatcher.running_in_this_thread();
46 template <
typename Dispatcher,
typename Handler,
51 typedef void result_type;
54 : dispatcher_(dispatcher),
55 handler_(ASIO_MOVE_CAST(Handler)(handler))
59 #if defined(ASIO_HAS_MOVE) 61 : dispatcher_(other.dispatcher_),
62 handler_(other.handler_)
67 : dispatcher_(other.dispatcher_),
68 handler_(ASIO_MOVE_CAST(Handler)(other.handler_))
71 #endif // defined(ASIO_HAS_MOVE) 75 dispatcher_.dispatch(ASIO_MOVE_CAST(Handler)(handler_));
78 void operator()()
const 80 dispatcher_.dispatch(handler_);
83 template <
typename Arg1>
84 void operator()(
const Arg1& arg1)
86 dispatcher_.dispatch(detail::bind_handler(handler_, arg1));
89 template <
typename Arg1>
90 void operator()(
const Arg1& arg1)
const 92 dispatcher_.dispatch(detail::bind_handler(handler_, arg1));
95 template <
typename Arg1,
typename Arg2>
96 void operator()(
const Arg1& arg1,
const Arg2& arg2)
98 dispatcher_.dispatch(detail::bind_handler(handler_, arg1, arg2));
101 template <
typename Arg1,
typename Arg2>
102 void operator()(
const Arg1& arg1,
const Arg2& arg2)
const 104 dispatcher_.dispatch(detail::bind_handler(handler_, arg1, arg2));
107 template <
typename Arg1,
typename Arg2,
typename Arg3>
108 void operator()(
const Arg1& arg1,
const Arg2& arg2,
const Arg3& arg3)
110 dispatcher_.dispatch(detail::bind_handler(handler_, arg1, arg2, arg3));
113 template <
typename Arg1,
typename Arg2,
typename Arg3>
114 void operator()(
const Arg1& arg1,
const Arg2& arg2,
const Arg3& arg3)
const 116 dispatcher_.dispatch(detail::bind_handler(handler_, arg1, arg2, arg3));
119 template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
120 void operator()(
const Arg1& arg1,
const Arg2& arg2,
const Arg3& arg3,
123 dispatcher_.dispatch(
124 detail::bind_handler(handler_, arg1, arg2, arg3, arg4));
127 template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
128 void operator()(
const Arg1& arg1,
const Arg2& arg2,
const Arg3& arg3,
129 const Arg4& arg4)
const 131 dispatcher_.dispatch(
132 detail::bind_handler(handler_, arg1, arg2, arg3, arg4));
135 template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
137 void operator()(
const Arg1& arg1,
const Arg2& arg2,
const Arg3& arg3,
138 const Arg4& arg4,
const Arg5& arg5)
140 dispatcher_.dispatch(
141 detail::bind_handler(handler_, arg1, arg2, arg3, arg4, arg5));
144 template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
146 void operator()(
const Arg1& arg1,
const Arg2& arg2,
const Arg3& arg3,
147 const Arg4& arg4,
const Arg5& arg5)
const 149 dispatcher_.dispatch(
150 detail::bind_handler(handler_, arg1, arg2, arg3, arg4, arg5));
154 Dispatcher dispatcher_;
158 template <
typename Handler,
typename Context>
164 handler_(ASIO_MOVE_CAST(Handler)(handler))
174 #if defined(ASIO_HAS_MOVE) 176 : context_(other.context_),
177 handler_(other.handler_)
182 : context_(ASIO_MOVE_CAST(Context)(other.context_)),
183 handler_(ASIO_MOVE_CAST(Handler)(other.handler_))
186 #endif // defined(ASIO_HAS_MOVE) 193 void operator()()
const 203 template <
typename Dispatcher,
typename Handler,
typename IsContinuation>
204 inline asio_handler_allocate_is_deprecated
205 asio_handler_allocate(std::size_t size,
208 #if defined(ASIO_NO_DEPRECATED) 209 asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
210 return asio_handler_allocate_is_no_longer_used();
211 #else // defined(ASIO_NO_DEPRECATED) 212 return asio_handler_alloc_helpers::allocate(
213 size, this_handler->handler_);
214 #endif // defined(ASIO_NO_DEPRECATED) 217 template <
typename Dispatcher,
typename Handler,
typename IsContinuation>
218 inline asio_handler_deallocate_is_deprecated
219 asio_handler_deallocate(
void* pointer, std::size_t size,
222 asio_handler_alloc_helpers::deallocate(
223 pointer, size, this_handler->handler_);
224 #if defined(ASIO_NO_DEPRECATED) 225 return asio_handler_deallocate_is_no_longer_used();
226 #endif // defined(ASIO_NO_DEPRECATED) 229 template <
typename Dispatcher,
typename Handler,
typename IsContinuation>
230 inline bool asio_handler_is_continuation(
233 return IsContinuation()(this_handler->dispatcher_, this_handler->handler_);
236 template <
typename Function,
typename Dispatcher,
237 typename Handler,
typename IsContinuation>
238 inline asio_handler_invoke_is_deprecated
242 this_handler->dispatcher_.dispatch(
244 function, this_handler->handler_));
245 #if defined(ASIO_NO_DEPRECATED) 246 return asio_handler_invoke_is_no_longer_used();
247 #endif // defined(ASIO_NO_DEPRECATED) 250 template <
typename Function,
typename Dispatcher,
251 typename Handler,
typename IsContinuation>
252 inline asio_handler_invoke_is_deprecated
256 this_handler->dispatcher_.dispatch(
258 function, this_handler->handler_));
259 #if defined(ASIO_NO_DEPRECATED) 260 return asio_handler_invoke_is_no_longer_used();
261 #endif // defined(ASIO_NO_DEPRECATED) 264 template <
typename Handler,
typename Context>
265 inline asio_handler_allocate_is_deprecated
266 asio_handler_allocate(std::size_t size,
269 #if defined(ASIO_NO_DEPRECATED) 270 asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
271 return asio_handler_allocate_is_no_longer_used();
272 #else // defined(ASIO_NO_DEPRECATED) 273 return asio_handler_alloc_helpers::allocate(
274 size, this_handler->handler_);
275 #endif // defined(ASIO_NO_DEPRECATED) 278 template <
typename Handler,
typename Context>
279 inline asio_handler_deallocate_is_deprecated
280 asio_handler_deallocate(
void* pointer, std::size_t size,
283 asio_handler_alloc_helpers::deallocate(
284 pointer, size, this_handler->context_);
285 #if defined(ASIO_NO_DEPRECATED) 286 return asio_handler_deallocate_is_no_longer_used();
287 #endif // defined(ASIO_NO_DEPRECATED) 290 template <
typename Dispatcher,
typename Context>
291 inline bool asio_handler_is_continuation(
294 return asio_handler_cont_helpers::is_continuation(
295 this_handler->context_);
298 template <
typename Function,
typename Handler,
typename Context>
299 inline asio_handler_invoke_is_deprecated
303 asio_handler_invoke_helpers::invoke(
304 function, this_handler->context_);
305 #if defined(ASIO_NO_DEPRECATED) 306 return asio_handler_invoke_is_no_longer_used();
307 #endif // defined(ASIO_NO_DEPRECATED) 310 template <
typename Function,
typename Handler,
typename Context>
311 inline asio_handler_invoke_is_deprecated
315 asio_handler_invoke_helpers::invoke(
316 function, this_handler->context_);
317 #if defined(ASIO_NO_DEPRECATED) 318 return asio_handler_invoke_is_no_longer_used();
319 #endif // defined(ASIO_NO_DEPRECATED) 325 #include "asio/detail/pop_options.hpp" 327 #endif // ASIO_DETAIL_WRAPPED_HANDLER_HPP asio_handler_invoke_is_deprecated asio_handler_invoke(Function &function,...)
Default handler invocation hook used for non-const function objects.
Definition: handler_invoke_hook.hpp:85
Definition: wrapped_handler.hpp:28
Definition: wrapped_handler.hpp:159
Definition: wrapped_handler.hpp:48
Definition: wrapped_handler.hpp:37
Definition: any_io_executor.hpp:28