summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/detail/impl/reactive_descriptor_service.ipp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/detail/impl/reactive_descriptor_service.ipp')
-rw-r--r--3rdparty/asio/include/asio/detail/impl/reactive_descriptor_service.ipp51
1 files changed, 34 insertions, 17 deletions
diff --git a/3rdparty/asio/include/asio/detail/impl/reactive_descriptor_service.ipp b/3rdparty/asio/include/asio/detail/impl/reactive_descriptor_service.ipp
index 7aaf3620f16..829aefb01bf 100644
--- a/3rdparty/asio/include/asio/detail/impl/reactive_descriptor_service.ipp
+++ b/3rdparty/asio/include/asio/detail/impl/reactive_descriptor_service.ipp
@@ -2,7 +2,7 @@
// detail/impl/reactive_descriptor_service.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2024 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)
@@ -19,7 +19,8 @@
#if !defined(ASIO_WINDOWS) \
&& !defined(ASIO_WINDOWS_RUNTIME) \
- && !defined(__CYGWIN__)
+ && !defined(__CYGWIN__) \
+ && !defined(ASIO_HAS_IO_URING_AS_DEFAULT)
#include "asio/error.hpp"
#include "asio/detail/reactive_descriptor_service.hpp"
@@ -30,9 +31,9 @@ namespace asio {
namespace detail {
reactive_descriptor_service::reactive_descriptor_service(
- asio::io_context& io_context)
- : service_base<reactive_descriptor_service>(io_context),
- reactor_(asio::use_service<reactor>(io_context))
+ execution_context& context)
+ : execution_context_service_base<reactive_descriptor_service>(context),
+ reactor_(asio::use_service<reactor>(context))
{
reactor_.init_task();
}
@@ -46,11 +47,13 @@ void reactive_descriptor_service::construct(
{
impl.descriptor_ = -1;
impl.state_ = 0;
+ impl.reactor_data_ = reactor::per_descriptor_data();
}
void reactive_descriptor_service::move_construct(
reactive_descriptor_service::implementation_type& impl,
reactive_descriptor_service::implementation_type& other_impl)
+ noexcept
{
impl.descriptor_ = other_impl.descriptor_;
other_impl.descriptor_ = -1;
@@ -89,10 +92,12 @@ void reactive_descriptor_service::destroy(
reactor_.deregister_descriptor(impl.descriptor_, impl.reactor_data_,
(impl.state_ & descriptor_ops::possible_dup) == 0);
- }
- asio::error_code ignored_ec;
- descriptor_ops::close(impl.descriptor_, impl.state_, ignored_ec);
+ asio::error_code ignored_ec;
+ descriptor_ops::close(impl.descriptor_, impl.state_, ignored_ec);
+
+ reactor_.cleanup_descriptor_data(impl.reactor_data_);
+ }
}
asio::error_code reactive_descriptor_service::assign(
@@ -102,6 +107,7 @@ asio::error_code reactive_descriptor_service::assign(
if (is_open(impl))
{
ec = asio::error::already_open;
+ ASIO_ERROR_LOCATION(ec);
return ec;
}
@@ -110,6 +116,7 @@ asio::error_code reactive_descriptor_service::assign(
{
ec = asio::error_code(err,
asio::error::get_system_category());
+ ASIO_ERROR_LOCATION(ec);
return ec;
}
@@ -130,9 +137,15 @@ asio::error_code reactive_descriptor_service::close(
reactor_.deregister_descriptor(impl.descriptor_, impl.reactor_data_,
(impl.state_ & descriptor_ops::possible_dup) == 0);
- }
- descriptor_ops::close(impl.descriptor_, impl.state_, ec);
+ descriptor_ops::close(impl.descriptor_, impl.state_, ec);
+
+ reactor_.cleanup_descriptor_data(impl.reactor_data_);
+ }
+ else
+ {
+ ec = asio::error_code();
+ }
// The descriptor is closed by the OS even if close() returns an error.
//
@@ -142,6 +155,7 @@ asio::error_code reactive_descriptor_service::close(
// We'll just have to assume that other OSes follow the same behaviour.)
construct(impl);
+ ASIO_ERROR_LOCATION(ec);
return ec;
}
@@ -157,6 +171,7 @@ reactive_descriptor_service::release(
"descriptor", &impl, impl.descriptor_, "release"));
reactor_.deregister_descriptor(impl.descriptor_, impl.reactor_data_, false);
+ reactor_.cleanup_descriptor_data(impl.reactor_data_);
construct(impl);
}
@@ -170,6 +185,7 @@ asio::error_code reactive_descriptor_service::cancel(
if (!is_open(impl))
{
ec = asio::error::bad_descriptor;
+ ASIO_ERROR_LOCATION(ec);
return ec;
}
@@ -181,10 +197,10 @@ asio::error_code reactive_descriptor_service::cancel(
return ec;
}
-void reactive_descriptor_service::start_op(
- reactive_descriptor_service::implementation_type& impl,
- int op_type, reactor_op* op, bool is_continuation,
- bool is_non_blocking, bool noop)
+void reactive_descriptor_service::do_start_op(implementation_type& impl,
+ int op_type, reactor_op* op, bool is_continuation, bool is_non_blocking,
+ bool noop, void (*on_immediate)(operation* op, bool, const void*),
+ const void* immediate_arg)
{
if (!noop)
{
@@ -192,13 +208,13 @@ void reactive_descriptor_service::start_op(
descriptor_ops::set_internal_non_blocking(
impl.descriptor_, impl.state_, true, op->ec_))
{
- reactor_.start_op(op_type, impl.descriptor_,
- impl.reactor_data_, op, is_continuation, is_non_blocking);
+ reactor_.start_op(op_type, impl.descriptor_, impl.reactor_data_, op,
+ is_continuation, is_non_blocking, on_immediate, immediate_arg);
return;
}
}
- reactor_.post_immediate_completion(op, is_continuation);
+ on_immediate(op, is_continuation, immediate_arg);
}
} // namespace detail
@@ -209,5 +225,6 @@ void reactive_descriptor_service::start_op(
#endif // !defined(ASIO_WINDOWS)
// && !defined(ASIO_WINDOWS_RUNTIME)
// && !defined(__CYGWIN__)
+ // && !defined(ASIO_HAS_IO_URING_AS_DEFAULT)
#endif // ASIO_DETAIL_IMPL_REACTIVE_DESCRIPTOR_SERVICE_IPP