Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

spawn

Boost , Boost.Asio , Reference

Boost C++ Libraries

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

PrevUpHomeNext

Начните новый сложный курс.

template<
    typename Handler,
    typename Function>
void spawn(
    Handler handler,
    Function function,
    const boost::coroutines::attributes & attributes = boost::coroutines::attributes());
  » more...
template<
    typename Handler,
    typename Function>
void spawn(
    basic_yield_context< Handler > ctx,
    Function function,
    const boost::coroutines::attributes & attributes = boost::coroutines::attributes());
  » more...
template<
    typename Function>
void spawn(
    boost::asio::io_service::strand strand,
    Function function,
    const boost::coroutines::attributes & attributes = boost::coroutines::attributes());
  » more...
template<
    typename Function>
void spawn(
    boost::asio::io_service & io_service,
    Function function,
    const boost::coroutines::attributes & attributes = boost::coroutines::attributes());
  » more...

Функция spawn() представляет собой высокоуровневую обертку над Boost. Корутинная библиотека. Эта функция позволяет программам реализовывать асинхронную логику синхронно, как показано на следующем примере:

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

Руководитель: boost/asio/spawn.hpp

Заголовок удобства: Никто


PrevUpHomeNext

Статья spawn раздела Boost.Asio Reference может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: Reference ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-19 23:18:49/0.0062320232391357/0