More spawn() changes to support standard executors.
This commit is contained in:
parent
af58116845
commit
8b0eb52f8a
@ -362,6 +362,20 @@ namespace detail {
|
||||
template <typename Handler, typename Function>
|
||||
struct spawn_helper
|
||||
{
|
||||
typedef typename associated_allocator<Handler>::type allocator_type;
|
||||
|
||||
allocator_type get_allocator() const ASIO_NOEXCEPT
|
||||
{
|
||||
return (get_associated_allocator)(data_->handler_);
|
||||
}
|
||||
|
||||
typedef typename associated_executor<Handler>::type executor_type;
|
||||
|
||||
executor_type get_executor() const ASIO_NOEXCEPT
|
||||
{
|
||||
return (get_associated_executor)(data_->handler_);
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
typedef typename basic_yield_context<Handler>::callee_type callee_type;
|
||||
@ -427,12 +441,6 @@ void spawn(ASIO_MOVE_ARG(Handler) handler,
|
||||
typedef typename decay<Handler>::type handler_type;
|
||||
typedef typename decay<Function>::type function_type;
|
||||
|
||||
typename associated_executor<handler_type>::type ex(
|
||||
(get_associated_executor)(handler));
|
||||
|
||||
typename associated_allocator<handler_type>::type a(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
detail::spawn_helper<handler_type, function_type> helper;
|
||||
helper.data_.reset(
|
||||
new detail::spawn_data<handler_type, function_type>(
|
||||
@ -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 <typename Handler, typename Function>
|
||||
@ -452,12 +460,6 @@ void spawn(basic_yield_context<Handler> ctx,
|
||||
|
||||
Handler handler(ctx.handler_); // Explicit copy that might be moved from.
|
||||
|
||||
typename associated_executor<Handler>::type ex(
|
||||
(get_associated_executor)(handler));
|
||||
|
||||
typename associated_allocator<Handler>::type a(
|
||||
(get_associated_allocator)(handler));
|
||||
|
||||
detail::spawn_helper<Handler, function_type> helper;
|
||||
helper.data_.reset(
|
||||
new detail::spawn_data<Handler, function_type>(
|
||||
@ -465,7 +467,7 @@ void spawn(basic_yield_context<Handler> ctx,
|
||||
ASIO_MOVE_CAST(Function)(function)));
|
||||
helper.attributes_ = attributes;
|
||||
|
||||
ex.dispatch(helper, a);
|
||||
asio::dispatch(helper);
|
||||
}
|
||||
|
||||
template <typename Function, typename Executor>
|
||||
@ -490,6 +492,8 @@ inline void spawn(const strand<Executor>& ex,
|
||||
ASIO_MOVE_CAST(Function)(function), attributes);
|
||||
}
|
||||
|
||||
#if !defined(ASIO_NO_TS_EXECUTORS)
|
||||
|
||||
template <typename Function>
|
||||
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 <typename Function, typename ExecutionContext>
|
||||
inline void spawn(ExecutionContext& ctx,
|
||||
ASIO_MOVE_ARG(Function) function,
|
||||
|
@ -289,6 +289,8 @@ void spawn(const strand<Executor>& 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.
|
||||
|
Loading…
Reference in New Issue
Block a user