Add spawn overload that just takes a function without a handler or executor.

This commit is contained in:
Christopher Kohlhoff 2014-11-02 18:23:58 -06:00
parent c1d4653363
commit 0372cdda34
2 changed files with 27 additions and 0 deletions

View File

@ -325,6 +325,18 @@ namespace detail {
} // namespace detail
template <typename Function>
inline void spawn(ASIO_MOVE_ARG(Function) function,
const boost::coroutines::attributes& attributes)
{
typedef typename decay<Function>::type function_type;
typename associated_executor<function_type>::type ex(
(get_associated_executor)(function));
asio::spawn(ex, ASIO_MOVE_CAST(Function)(function), attributes);
}
template <typename Handler, typename Function>
void spawn(ASIO_MOVE_ARG(Handler) handler,
ASIO_MOVE_ARG(Function) function,

View File

@ -190,6 +190,21 @@ typedef basic_yield_context<
*/
/*@{*/
/// Start a new stackful coroutine, calling the specified handler when it
/// completes.
/**
* This function is used to launch a new coroutine.
*
* @param function The coroutine function. The function must have the signature:
* @code void function(basic_yield_context<Handler> yield); @endcode
*
* @param attributes Boost.Coroutine attributes used to customise the coroutine.
*/
template <typename Function>
void spawn(ASIO_MOVE_ARG(Function) function,
const boost::coroutines::attributes& attributes
= boost::coroutines::attributes());
/// Start a new stackful coroutine, calling the specified handler when it
/// completes.
/**