Conditionally define immediate_executor_type in async_base

Fixes #3002
This commit is contained in:
Mohammad Nejati
2025-04-25 14:41:23 +00:00
committed by Mohammad Nejati
parent f60f7c152f
commit 78478557f6
2 changed files with 23 additions and 13 deletions

View File

@ -177,7 +177,8 @@ template<
>
class async_base
#if ! BOOST_BEAST_DOXYGEN
: private boost::empty_value<Allocator>
: public detail::with_immediate_executor_type<Handler>
, private boost::empty_value<Allocator>
#endif
{
static_assert(
@ -193,7 +194,7 @@ public:
If a class derived from @ref boost::beast::async_base is a completion
handler, then the associated executor of the derived class will
be this type.
*/
*/
using executor_type =
#if BOOST_BEAST_DOXYGEN
__implementation_defined__;
@ -210,19 +211,12 @@ public:
If a class derived from @ref boost::beast::async_base is a completion
handler, then the associated immediage executor of the derived class will
be this type.
*/
using immediate_executor_type =
*/
#if BOOST_BEAST_DOXYGEN
using immediate_executor_type =
__implementation_defined__;
#else
typename
net::associated_immediate_executor<
Handler,
typename detail::select_work_guard_t<Executor1>::executor_type
>::type;
#endif
private:
virtual
@ -333,8 +327,10 @@ public:
handler, then the object returned from this function will be used
as the associated immediate executor of the derived class.
*/
immediate_executor_type
auto
get_immediate_executor() const noexcept
-> decltype(net::get_associated_immediate_executor(
h_, wg1_.get_executor()))
{
return net::get_associated_immediate_executor(
h_, wg1_.get_executor());

View File

@ -10,7 +10,9 @@
#ifndef BOOST_BEAST_CORE_DETAIL_ASYNC_BASE_HPP
#define BOOST_BEAST_CORE_DETAIL_ASYNC_BASE_HPP
#include <boost/core/exchange.hpp>
#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/asio/associated_immediate_executor.hpp>
namespace boost {
namespace beast {
@ -39,6 +41,18 @@ protected:
virtual void destroy() = 0;
};
template<typename Handler, typename = void>
struct with_immediate_executor_type
{
};
template<typename Handler>
struct with_immediate_executor_type<Handler,
void_t<typename Handler::immediate_executor_type>>
{
using immediate_executor_type = typename Handler::immediate_executor_type;
};
} // detail
} // beast
} // boost