Realistic 3D camera system
3D camera system components
Functions
asio::spawn

Start a new stackful coroutine. More...

Functions

template<typename Handler , typename Function >
void asio::spawn (ASIO_MOVE_ARG(Handler) handler, ASIO_MOVE_ARG(Function) function, const boost::coroutines::attributes &attributes)
 
template<typename Handler , typename Function >
void asio::spawn (basic_yield_context< Handler > ctx, 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 asio::spawn (asio::io_service::strand strand, 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 asio::spawn (asio::io_service &io_service, 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...
 

Detailed Description

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:

asio::spawn(my_strand, do_echo);
// ...
{
try
{
char data[128];
for (;;)
{
std::size_t length =
my_socket.async_read_some(
asio::buffer(data), yield);
asio::async_write(my_socket,
asio::buffer(data, length), yield);
}
}
catch (std::exception& e)
{
// ...
}
}

Function Documentation

template<typename Handler , typename Function >
void asio::spawn ( ASIO_MOVE_ARG(Handler)  handler,
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. This function is used to launch a new coroutine.

Parameters
handlerA 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();
functionThe coroutine function. The function must have the signature:
void function(basic_yield_context<Handler> yield);
attributesBoost.Coroutine attributes used to customise the coroutine.

Definition at line 301 of file spawn.hpp.

template<typename Handler , typename Function >
void asio::spawn ( basic_yield_context< Handler >  ctx,
ASIO_MOVE_ARG(Function)  function,
const boost::coroutines::attributes &  attributes = boost::coroutines::attributes() 
)

Start a new stackful coroutine, inheriting the execution context of another.

This function is used to launch a new coroutine.

Parameters
ctxIdentifies 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.
functionThe coroutine function. The function must have the signature:
void function(basic_yield_context<Handler> yield);
attributesBoost.Coroutine attributes used to customise the coroutine.

Definition at line 315 of file spawn.hpp.

template<typename Function >
void asio::spawn ( asio::io_service::strand  strand,
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.

This function is used to launch a new coroutine.

Parameters
strandIdentifies a strand. By starting multiple coroutines on the same strand, the implementation ensures that none of those coroutines can execute simultaneously.
functionThe coroutine function. The function must have the signature:
void function(yield_context yield);
attributesBoost.Coroutine attributes used to customise the coroutine.

Definition at line 330 of file spawn.hpp.

template<typename Function >
void asio::spawn ( asio::io_service io_service,
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.

This function is used to launch a new coroutine.

Parameters
io_serviceIdentifies the io_service that will run the coroutine. The new coroutine is implicitly given its own strand within this io_service.
functionThe coroutine function. The function must have the signature:
void function(yield_context yield);
attributesBoost.Coroutine attributes used to customise the coroutine.

Definition at line 339 of file spawn.hpp.