Start a new stackful coroutine. More...
Functions | |
template<typename Handler , typename Function > | |
void | boost::asio::spawn (BOOST_ASIO_MOVE_ARG(Handler) handler, BOOST_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. More... | |
template<typename Handler , typename Function > | |
void | boost::asio::spawn (basic_yield_context< Handler > ctx, BOOST_ASIO_MOVE_ARG(Function) function, const boost::coroutines::attributes &attributes=boost::coroutines::attributes()) |
Start a new stackful coroutine, inheriting the execution context of another. More... | |
template<typename Function > | |
void | boost::asio::spawn (boost::asio::io_service::strand strand, BOOST_ASIO_MOVE_ARG(Function) function, const boost::coroutines::attributes &attributes=boost::coroutines::attributes()) |
Start a new stackful coroutine that executes in the context of a strand. More... | |
template<typename Function > | |
void | boost::asio::spawn (boost::asio::io_service &io_service, BOOST_ASIO_MOVE_ARG(Function) function, const boost::coroutines::attributes &attributes=boost::coroutines::attributes()) |
Start a new stackful coroutine that executes on a given io_service. More... | |
Start a new stackful coroutine.
The spawn() function is a high-level wrapper over the Boost.Coroutine library. This function enables programs to implement asynchronous logic in a synchronous manner, as illustrated by the following example:
void boost::asio::spawn | ( | BOOST_ASIO_MOVE_ARG(Handler) | handler, |
BOOST_ASIO_MOVE_ARG(Function) | function, | ||
const boost::coroutines::attributes & | attributes = boost::coroutines::attributes() |
||
) |
#include <boost_1_57_0/boost/asio/spawn.hpp>
Start a new stackful coroutine, calling the specified handler when it completes.
This function is used to launch a new coroutine.
handler | 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();
|
function | The coroutine function. The function must have the signature: |
attributes | Boost.Coroutine attributes used to customise the coroutine. |
void boost::asio::spawn | ( | basic_yield_context< Handler > | ctx, |
BOOST_ASIO_MOVE_ARG(Function) | function, | ||
const boost::coroutines::attributes & | attributes = boost::coroutines::attributes() |
||
) |
#include <boost_1_57_0/boost/asio/spawn.hpp>
Start a new stackful coroutine, inheriting the execution context of another.
This function is used to launch a new coroutine.
ctx | Identifies the current coroutine as a parent of the new coroutine. This specifies that the new coroutine should inherit the execution context of the parent. For example, if the parent coroutine is executing in a particular strand, then the new coroutine will execute in the same strand. |
function | The coroutine function. The function must have the signature: |
attributes | Boost.Coroutine attributes used to customise the coroutine. |
void boost::asio::spawn | ( | boost::asio::io_service::strand | strand, |
BOOST_ASIO_MOVE_ARG(Function) | function, | ||
const boost::coroutines::attributes & | attributes = boost::coroutines::attributes() |
||
) |
#include <boost_1_57_0/boost/asio/spawn.hpp>
Start a new stackful coroutine that executes in the context of a strand.
This function is used to launch a new coroutine.
strand | Identifies a strand. By starting multiple coroutines on the same strand, the implementation ensures that none of those coroutines can execute simultaneously. |
function | The coroutine function. The function must have the signature: |
attributes | Boost.Coroutine attributes used to customise the coroutine. |
void boost::asio::spawn | ( | boost::asio::io_service & | io_service, |
BOOST_ASIO_MOVE_ARG(Function) | function, | ||
const boost::coroutines::attributes & | attributes = boost::coroutines::attributes() |
||
) |
#include <boost_1_57_0/boost/asio/spawn.hpp>
Start a new stackful coroutine that executes on a given io_service.
This function is used to launch a new coroutine.
io_service | Identifies the io_service that will run the coroutine. The new coroutine is implicitly given its own strand within this io_service. |
function | The coroutine function. The function must have the signature: |
attributes | Boost.Coroutine attributes used to customise the coroutine. |