Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

spawn (8 of 13 overloads)

(Deprecated: Use overloads with a completion token.) Start a new stackful coroutine, calling the specified handler when it completes.

    typename Handler,
    typename Function>
void spawn(
    Handler && handler,
    Function && function,
    const boost::coroutines::attributes & attributes = boost::coroutines::attributes(),
    typename constraint< !is_executor< typename decay< Handler >::type >::value &&!execution::is_executor< typename decay< Handler >::type >::value &&!is_convertible< Handler &, execution_context & >::value >::type  = 0);

This function is used to launch a new coroutine.



A handler to be called when the coroutine exits. More importantly, the handler provides an execution context (via the the handler invocation hook) for the coroutine. The handler must have the signature:

void handler();

The coroutine function. The function must have the signature:

void function(basic_yield_context<Executor> yield);

where Executor is the associated executor type of Handler.


Boost.Coroutine attributes used to customise the coroutine.