diff --git a/include/boost/beast/core/detail/get_io_context.hpp b/include/boost/beast/core/detail/get_io_context.hpp index 7733b58e..b065cceb 100644 --- a/include/boost/beast/core/detail/get_io_context.hpp +++ b/include/boost/beast/core/detail/get_io_context.hpp @@ -34,7 +34,7 @@ inline net::io_context* get_io_context(net::io_context::executor_type const& ex) { - return std::addressof(ex.context()); + return std::addressof(net::query(ex, net::execution::context)); } inline @@ -42,8 +42,7 @@ net::io_context* get_io_context(net::strand< net::io_context::executor_type> const& ex) { - return std::addressof( - ex.get_inner_executor().context()); + return get_io_context(ex.get_inner_executor()); } template @@ -64,7 +63,7 @@ get_io_context(T const& ex) net::io_context::executor_type>(); if(! p) return nullptr; - return std::addressof(p->context()); + return get_io_context(*p); } inline diff --git a/test/beast/core/bind_handler.cpp b/test/beast/core/bind_handler.cpp index 20830deb..eb228bdb 100644 --- a/test/beast/core/bind_handler.cpp +++ b/test/beast/core/bind_handler.cpp @@ -80,7 +80,11 @@ public: class test_executor { bind_handler_test& s_; +#if defined(BOOST_ASIO_NO_TS_EXECUTORS) net::any_io_executor ex_; +#else + net::io_context::executor_type ex_; +#endif // Storing the blocking property as a member is not strictly necessary, // as we could simply forward the calls @@ -118,6 +122,7 @@ public: return ex_ != other.ex_; } +#if defined(BOOST_ASIO_NO_TS_EXECUTORS) net::execution_context& query(net::execution::context_t c) const noexcept { return net::query(ex_, c); @@ -176,6 +181,7 @@ public: BEAST_FAIL(); } } +#endif #if !defined(BOOST_ASIO_NO_TS_EXECUTORS) net::execution_context& @@ -198,7 +204,13 @@ public: void dispatch(F&& f, Alloc const& a) { s_.on_invoke(); - ex_.dispatch(std::forward(f), a); + net::execution::execute( + net::prefer(ex_, + net::execution::blocking.possibly, + net::execution::allocator(a)), + std::forward(f)); + // previously equivalent to + // ex_.dispatch(std::forward(f), a); } template @@ -219,6 +231,27 @@ public: #endif // !defined(BOOST_ASIO_NO_TS_EXECUTORS) }; +#if defined(BOOST_ASIO_NO_TS_EXECUTORS) + using F = net::execution::invocable_archetype; + using T = test_executor; + + BOOST_STATIC_ASSERT( + conditional::type&()>::type + >::type::value); + + BOOST_STATIC_ASSERT(std::is_constructible::type, F>::value); + BOOST_STATIC_ASSERT(std::is_move_constructible::type>::value); + BOOST_STATIC_ASSERT(boost::asio::execution::can_execute::value); + BOOST_STATIC_ASSERT(std::is_nothrow_copy_constructible::value); + BOOST_STATIC_ASSERT(std::is_nothrow_destructible::value); + BOOST_STATIC_ASSERT(boost::asio::traits::equality_comparable::is_valid); + BOOST_STATIC_ASSERT(boost::asio::traits::equality_comparable::is_noexcept); + BOOST_STATIC_ASSERT(net::execution::is_executor_v); +#else + BOOST_STATIC_ASSERT(net::is_executor::value); +#endif + class test_cb { bool fail_ = true;