resolver_service_base.ipp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // detail/impl/resolver_service_base.ipp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_DETAIL_IMPL_RESOLVER_SERVICE_BASE_IPP
  11. #define BOOST_ASIO_DETAIL_IMPL_RESOLVER_SERVICE_BASE_IPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/config.hpp>
  17. #include <boost/asio/detail/memory.hpp>
  18. #include <boost/asio/detail/resolver_service_base.hpp>
  19. #include <boost/asio/detail/push_options.hpp>
  20. namespace boost {
  21. namespace asio {
  22. namespace detail {
  23. resolver_service_base::resolver_service_base(execution_context& context)
  24. : thread_pool_(boost::asio::use_service<resolver_thread_pool>(context))
  25. {
  26. }
  27. resolver_service_base::~resolver_service_base()
  28. {
  29. }
  30. void resolver_service_base::construct(
  31. resolver_service_base::implementation_type& impl)
  32. {
  33. impl.reset(static_cast<void*>(0), socket_ops::noop_deleter());
  34. }
  35. void resolver_service_base::destroy(
  36. resolver_service_base::implementation_type& impl)
  37. {
  38. BOOST_ASIO_HANDLER_OPERATION((thread_pool_.context(),
  39. "resolver", &impl, 0, "cancel"));
  40. impl.reset();
  41. }
  42. void resolver_service_base::move_construct(implementation_type& impl,
  43. implementation_type& other_impl)
  44. {
  45. impl = static_cast<implementation_type&&>(other_impl);
  46. }
  47. void resolver_service_base::move_assign(implementation_type& impl,
  48. resolver_service_base&, implementation_type& other_impl)
  49. {
  50. destroy(impl);
  51. impl = static_cast<implementation_type&&>(other_impl);
  52. }
  53. void resolver_service_base::cancel(
  54. resolver_service_base::implementation_type& impl)
  55. {
  56. BOOST_ASIO_HANDLER_OPERATION((thread_pool_.context(),
  57. "resolver", &impl, 0, "cancel"));
  58. impl.reset(static_cast<void*>(0), socket_ops::noop_deleter());
  59. }
  60. } // namespace detail
  61. } // namespace asio
  62. } // namespace boost
  63. #include <boost/asio/detail/pop_options.hpp>
  64. #endif // BOOST_ASIO_DETAIL_IMPL_RESOLVER_SERVICE_BASE_IPP