diff --git a/asio/include/asio/impl/spawn.hpp b/asio/include/asio/impl/spawn.hpp index 195d686e..6337be2c 100644 --- a/asio/include/asio/impl/spawn.hpp +++ b/asio/include/asio/impl/spawn.hpp @@ -362,6 +362,20 @@ namespace detail { template struct spawn_helper { + typedef typename associated_allocator::type allocator_type; + + allocator_type get_allocator() const ASIO_NOEXCEPT + { + return (get_associated_allocator)(data_->handler_); + } + + typedef typename associated_executor::type executor_type; + + executor_type get_executor() const ASIO_NOEXCEPT + { + return (get_associated_executor)(data_->handler_); + } + void operator()() { typedef typename basic_yield_context::callee_type callee_type; @@ -427,12 +441,6 @@ void spawn(ASIO_MOVE_ARG(Handler) handler, typedef typename decay::type handler_type; typedef typename decay::type function_type; - typename associated_executor::type ex( - (get_associated_executor)(handler)); - - typename associated_allocator::type a( - (get_associated_allocator)(handler)); - detail::spawn_helper helper; helper.data_.reset( new detail::spawn_data( @@ -440,7 +448,7 @@ void spawn(ASIO_MOVE_ARG(Handler) handler, ASIO_MOVE_CAST(Function)(function))); helper.attributes_ = attributes; - ex.dispatch(helper, a); + asio::dispatch(helper); } template @@ -452,12 +460,6 @@ void spawn(basic_yield_context ctx, Handler handler(ctx.handler_); // Explicit copy that might be moved from. - typename associated_executor::type ex( - (get_associated_executor)(handler)); - - typename associated_allocator::type a( - (get_associated_allocator)(handler)); - detail::spawn_helper helper; helper.data_.reset( new detail::spawn_data( @@ -465,7 +467,7 @@ void spawn(basic_yield_context ctx, ASIO_MOVE_CAST(Function)(function))); helper.attributes_ = attributes; - ex.dispatch(helper, a); + asio::dispatch(helper); } template @@ -490,6 +492,8 @@ inline void spawn(const strand& ex, ASIO_MOVE_CAST(Function)(function), attributes); } +#if !defined(ASIO_NO_TS_EXECUTORS) + template inline void spawn(const asio::io_context::strand& s, ASIO_MOVE_ARG(Function) function, @@ -500,6 +504,8 @@ inline void spawn(const asio::io_context::strand& s, ASIO_MOVE_CAST(Function)(function), attributes); } +#endif // !defined(ASIO_NO_TS_EXECUTORS) + template inline void spawn(ExecutionContext& ctx, ASIO_MOVE_ARG(Function) function, diff --git a/asio/include/asio/spawn.hpp b/asio/include/asio/spawn.hpp index c8603abb..ba000977 100644 --- a/asio/include/asio/spawn.hpp +++ b/asio/include/asio/spawn.hpp @@ -289,6 +289,8 @@ void spawn(const strand& ex, const boost::coroutines::attributes& attributes = boost::coroutines::attributes()); +#if !defined(ASIO_NO_TS_EXECUTORS) + /// Start a new stackful coroutine that executes in the context of a strand. /** * This function is used to launch a new coroutine. @@ -308,6 +310,8 @@ void spawn(const asio::io_context::strand& s, const boost::coroutines::attributes& attributes = boost::coroutines::attributes()); +#endif // !defined(ASIO_NO_TS_EXECUTORS) + /// Start a new stackful coroutine that executes on a given execution context. /** * This function is used to launch a new coroutine.