summaryrefslogtreecommitdiff
path: root/boost/asio/detail/resolve_endpoint_op.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/asio/detail/resolve_endpoint_op.hpp')
-rw-r--r--boost/asio/detail/resolve_endpoint_op.hpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/boost/asio/detail/resolve_endpoint_op.hpp b/boost/asio/detail/resolve_endpoint_op.hpp
index 970544c783..72df8d94ac 100644
--- a/boost/asio/detail/resolve_endpoint_op.hpp
+++ b/boost/asio/detail/resolve_endpoint_op.hpp
@@ -2,7 +2,7 @@
// detail/resolve_endpoint_op.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -17,7 +17,6 @@
#include <boost/asio/detail/config.hpp>
#include <boost/asio/error.hpp>
-#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/basic_resolver_results.hpp>
#include <boost/asio/detail/bind_handler.hpp>
#include <boost/asio/detail/fenced_block.hpp>
@@ -27,13 +26,19 @@
#include <boost/asio/detail/resolve_op.hpp>
#include <boost/asio/detail/socket_ops.hpp>
+#if defined(BOOST_ASIO_HAS_IOCP)
+# include <boost/asio/detail/win_iocp_io_context.hpp>
+#else // defined(BOOST_ASIO_HAS_IOCP)
+# include <boost/asio/detail/scheduler.hpp>
+#endif // defined(BOOST_ASIO_HAS_IOCP)
+
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace detail {
-template <typename Protocol, typename Handler>
+template <typename Protocol, typename Handler, typename IoExecutor>
class resolve_endpoint_op : public resolve_op
{
public:
@@ -42,15 +47,23 @@ public:
typedef typename Protocol::endpoint endpoint_type;
typedef boost::asio::ip::basic_resolver_results<Protocol> results_type;
+#if defined(BOOST_ASIO_HAS_IOCP)
+ typedef class win_iocp_io_context scheduler_impl;
+#else
+ typedef class scheduler scheduler_impl;
+#endif
+
resolve_endpoint_op(socket_ops::weak_cancel_token_type cancel_token,
- const endpoint_type& endpoint, io_context_impl& ioc, Handler& handler)
+ const endpoint_type& endpoint, scheduler_impl& sched,
+ Handler& handler, const IoExecutor& io_ex)
: resolve_op(&resolve_endpoint_op::do_complete),
cancel_token_(cancel_token),
endpoint_(endpoint),
- io_context_impl_(ioc),
- handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
+ scheduler_(sched),
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
+ io_executor_(io_ex)
{
- handler_work<Handler>::start(handler_);
+ handler_work<Handler, IoExecutor>::start(handler_, io_executor_);
}
static void do_complete(void* owner, operation* base,
@@ -60,9 +73,9 @@ public:
// Take ownership of the operation object.
resolve_endpoint_op* o(static_cast<resolve_endpoint_op*>(base));
ptr p = { boost::asio::detail::addressof(o->handler_), o, o };
- handler_work<Handler> w(o->handler_);
+ handler_work<Handler, IoExecutor> w(o->handler_, o->io_executor_);
- if (owner && owner != &o->io_context_impl_)
+ if (owner && owner != &o->scheduler_)
{
// The operation is being run on the worker io_context. Time to perform
// the resolver operation.
@@ -76,7 +89,7 @@ public:
o->results_ = results_type::create(o->endpoint_, host_name, service_name);
// Pass operation back to main io_context for completion.
- o->io_context_impl_.post_deferred_completion(o);
+ o->scheduler_.post_deferred_completion(o);
p.v = p.p = 0;
}
else
@@ -110,8 +123,9 @@ public:
private:
socket_ops::weak_cancel_token_type cancel_token_;
endpoint_type endpoint_;
- io_context_impl& io_context_impl_;
+ scheduler_impl& scheduler_;
Handler handler_;
+ IoExecutor io_executor_;
results_type results_;
};