summaryrefslogtreecommitdiff
path: root/boost/asio/detail/impl/resolver_service_base.ipp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:11:01 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:11:01 +0900
commit3fdc3e5ee96dca5b11d1694975a65200787eab86 (patch)
tree5c1733853892b8397d67706fa453a9bd978d2102 /boost/asio/detail/impl/resolver_service_base.ipp
parent88e602c57797660ebe0f9e15dbd64c1ff16dead3 (diff)
downloadboost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.gz
boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.bz2
boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.zip
Imported Upstream version 1.66.0upstream/1.66.0
Diffstat (limited to 'boost/asio/detail/impl/resolver_service_base.ipp')
-rw-r--r--boost/asio/detail/impl/resolver_service_base.ipp82
1 files changed, 53 insertions, 29 deletions
diff --git a/boost/asio/detail/impl/resolver_service_base.ipp b/boost/asio/detail/impl/resolver_service_base.ipp
index 4ef66cde15..1dbbd20c3f 100644
--- a/boost/asio/detail/impl/resolver_service_base.ipp
+++ b/boost/asio/detail/impl/resolver_service_base.ipp
@@ -24,62 +24,62 @@ namespace boost {
namespace asio {
namespace detail {
-class resolver_service_base::work_io_service_runner
+class resolver_service_base::work_io_context_runner
{
public:
- work_io_service_runner(boost::asio::io_service& io_service)
- : io_service_(io_service) {}
- void operator()() { io_service_.run(); }
+ work_io_context_runner(boost::asio::io_context& io_context)
+ : io_context_(io_context) {}
+ void operator()() { io_context_.run(); }
private:
- boost::asio::io_service& io_service_;
+ boost::asio::io_context& io_context_;
};
resolver_service_base::resolver_service_base(
- boost::asio::io_service& io_service)
- : io_service_impl_(boost::asio::use_service<io_service_impl>(io_service)),
- work_io_service_(new boost::asio::io_service),
- work_io_service_impl_(boost::asio::use_service<
- io_service_impl>(*work_io_service_)),
- work_(new boost::asio::io_service::work(*work_io_service_)),
+ boost::asio::io_context& io_context)
+ : io_context_impl_(boost::asio::use_service<io_context_impl>(io_context)),
+ work_io_context_(new boost::asio::io_context(-1)),
+ work_io_context_impl_(boost::asio::use_service<
+ io_context_impl>(*work_io_context_)),
+ work_(boost::asio::make_work_guard(*work_io_context_)),
work_thread_(0)
{
}
resolver_service_base::~resolver_service_base()
{
- shutdown_service();
+ base_shutdown();
}
-void resolver_service_base::shutdown_service()
+void resolver_service_base::base_shutdown()
{
work_.reset();
- if (work_io_service_.get())
+ if (work_io_context_.get())
{
- work_io_service_->stop();
+ work_io_context_->stop();
if (work_thread_.get())
{
work_thread_->join();
work_thread_.reset();
}
- work_io_service_.reset();
+ work_io_context_.reset();
}
}
-void resolver_service_base::fork_service(
- boost::asio::io_service::fork_event fork_ev)
+void resolver_service_base::base_notify_fork(
+ boost::asio::io_context::fork_event fork_ev)
{
if (work_thread_.get())
{
- if (fork_ev == boost::asio::io_service::fork_prepare)
+ if (fork_ev == boost::asio::io_context::fork_prepare)
{
- work_io_service_->stop();
+ work_io_context_->stop();
work_thread_->join();
}
else
{
- work_io_service_->reset();
+ work_io_context_->restart();
work_thread_.reset(new boost::asio::detail::thread(
- work_io_service_runner(*work_io_service_)));
+ work_io_context_runner(*work_io_context_)));
}
}
}
@@ -93,24 +93,48 @@ void resolver_service_base::construct(
void resolver_service_base::destroy(
resolver_service_base::implementation_type& impl)
{
- BOOST_ASIO_HANDLER_OPERATION(("resolver", &impl, "cancel"));
+ BOOST_ASIO_HANDLER_OPERATION((io_context_impl_.context(),
+ "resolver", &impl, 0, "cancel"));
impl.reset();
}
+void resolver_service_base::move_construct(implementation_type& impl,
+ implementation_type& other_impl)
+{
+ impl = BOOST_ASIO_MOVE_CAST(implementation_type)(other_impl);
+}
+
+void resolver_service_base::move_assign(implementation_type& impl,
+ resolver_service_base&, implementation_type& other_impl)
+{
+ destroy(impl);
+ impl = BOOST_ASIO_MOVE_CAST(implementation_type)(other_impl);
+}
+
void resolver_service_base::cancel(
resolver_service_base::implementation_type& impl)
{
- BOOST_ASIO_HANDLER_OPERATION(("resolver", &impl, "cancel"));
+ BOOST_ASIO_HANDLER_OPERATION((io_context_impl_.context(),
+ "resolver", &impl, 0, "cancel"));
impl.reset(static_cast<void*>(0), socket_ops::noop_deleter());
}
-void resolver_service_base::start_resolve_op(operation* op)
+void resolver_service_base::start_resolve_op(resolve_op* op)
{
- start_work_thread();
- io_service_impl_.work_started();
- work_io_service_impl_.post_immediate_completion(op, false);
+ if (BOOST_ASIO_CONCURRENCY_HINT_IS_LOCKING(SCHEDULER,
+ io_context_impl_.concurrency_hint()))
+ {
+ start_work_thread();
+ io_context_impl_.work_started();
+ work_io_context_impl_.post_immediate_completion(op, false);
+ }
+ else
+ {
+ op->ec_ = boost::asio::error::operation_not_supported;
+ io_context_impl_.post_immediate_completion(op, false);
+ }
}
void resolver_service_base::start_work_thread()
@@ -119,7 +143,7 @@ void resolver_service_base::start_work_thread()
if (!work_thread_.get())
{
work_thread_.reset(new boost::asio::detail::thread(
- work_io_service_runner(*work_io_service_)));
+ work_io_context_runner(*work_io_context_)));
}
}