]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/asio/detail/winrt_resolver_service.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / asio / detail / winrt_resolver_service.hpp
index 463dbde11fd8ac19110872d39f3a666b8f2131d5..054b6abfbc9db3bca6654f5d1101ae6de472d2a8 100644 (file)
@@ -2,7 +2,7 @@
 // detail/winrt_resolver_service.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)
@@ -21,6 +21,7 @@
 
 #include <boost/asio/ip/basic_resolver_query.hpp>
 #include <boost/asio/ip/basic_resolver_results.hpp>
+#include <boost/asio/post.hpp>
 #include <boost/asio/detail/bind_handler.hpp>
 #include <boost/asio/detail/memory.hpp>
 #include <boost/asio/detail/socket_ops.hpp>
 #include <boost/asio/detail/winrt_resolve_op.hpp>
 #include <boost/asio/detail/winrt_utils.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 {
@@ -36,7 +43,7 @@ namespace detail {
 
 template <typename Protocol>
 class winrt_resolver_service :
-  public service_base<winrt_resolver_service<Protocol> >
+  public execution_context_service_base<winrt_resolver_service<Protocol> >
 {
 public:
   // The implementation type of the resolver. A cancellation token is used to
@@ -54,10 +61,11 @@ public:
   typedef boost::asio::ip::basic_resolver_results<Protocol> results_type;
 
   // Constructor.
-  winrt_resolver_service(boost::asio::io_context& io_context)
-    : service_base<winrt_resolver_service<Protocol> >(io_context),
-      io_context_(use_service<io_context_impl>(io_context)),
-      async_manager_(use_service<winrt_async_manager>(io_context))
+  winrt_resolver_service(execution_context& context)
+    : execution_context_service_base<
+        winrt_resolver_service<Protocol> >(context),
+      scheduler_(use_service<scheduler_impl>(context)),
+      async_manager_(use_service<winrt_async_manager>(context))
   {
   }
 
@@ -72,7 +80,7 @@ public:
   }
 
   // Perform any fork-related housekeeping.
-  void notify_fork(boost::asio::io_context::fork_event)
+  void notify_fork(execution_context::fork_event)
   {
   }
 
@@ -131,20 +139,20 @@ public:
   }
 
   // Asynchronously resolve a query to a list of entries.
-  template <typename Handler>
-  void async_resolve(implementation_type& impl,
-      const query_type& query, Handler& handler)
+  template <typename Handler, typename IoExecutor>
+  void async_resolve(implementation_type& impl, const query_type& query,
+      Handler& handler, const IoExecutor& io_ex)
   {
     bool is_continuation =
       boost_asio_handler_cont_helpers::is_continuation(handler);
 
     // Allocate and construct an operation to wrap the handler.
-    typedef winrt_resolve_op<Protocol, Handler> op;
+    typedef winrt_resolve_op<Protocol, Handler, IoExecutor> op;
     typename op::ptr p = { boost::asio::detail::addressof(handler),
       op::ptr::allocate(handler), 0 };
-    p.p = new (p.v) op(query, handler);
+    p.p = new (p.v) op(query, handler, io_ex);
 
-    BOOST_ASIO_HANDLER_CREATION((io_context_.context(),
+    BOOST_ASIO_HANDLER_CREATION((scheduler_.context(),
           *p.p, "resolver", &impl, 0, "async_resolve"));
     (void)impl;
 
@@ -160,7 +168,7 @@ public:
     {
       p.p->ec_ = boost::system::error_code(
           e->HResult, boost::system::system_category());
-      io_context_.post_immediate_completion(p.p, is_continuation);
+      scheduler_.post_immediate_completion(p.p, is_continuation);
       p.v = p.p = 0;
     }
   }
@@ -174,18 +182,24 @@ public:
   }
 
   // Asynchronously resolve an endpoint to a list of entries.
-  template <typename Handler>
-  void async_resolve(implementation_type&,
-      const endpoint_type&, Handler& handler)
+  template <typename Handler, typename IoExecutor>
+  void async_resolve(implementation_type&, const endpoint_type&,
+      Handler& handler, const IoExecutor& io_ex)
   {
     boost::system::error_code ec = boost::asio::error::operation_not_supported;
     const results_type results;
-    io_context_.get_io_context().post(
-        detail::bind_handler(handler, ec, results));
+    boost::asio::post(io_ex, detail::bind_handler(handler, ec, results));
   }
 
 private:
-  io_context_impl& io_context_;
+  // The scheduler implementation used for delivering completions.
+#if defined(BOOST_ASIO_HAS_IOCP)
+  typedef class win_iocp_io_context scheduler_impl;
+#else
+  typedef class scheduler scheduler_impl;
+#endif
+  scheduler_impl& scheduler_;
+
   winrt_async_manager& async_manager_;
 };