Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Coroutine and Object Inheritance
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2013-12-19 12:28:16

2013/12/19 Carlos Ferreira <carlosmf.pt_at_[hidden]>

> 1.) do you know that boost.asio integrates boost.coroutine? example can be
>> read at
> Yes, I noticed that but I kinda got lost when I saw that spawn(...) used
> stackfull coroutines but at the boost::asio::coroutine documentation,
> stackless coroutines were described. I wanted to ensure I was using
> stackfull coroutines.

          boost::ref(io_service), atoi(argv[1]), _1));

spawn() creates internally a new coroutine with do_accept() as coroutine-fn
(do_accept() is executed by the coroutine) and passes io_serve and port as

> 2.) coroutine<> is a type holder, e.g. you have to derive from
>> coroutine<>::push_type or coroutine<>::pull_type
> I also saw that documentation and also got lost there... What is the
> difference between the push_type and pull_type? For what purposes should I
> use them?

with the new interface boost.coroutine provides unidirectional transfer of
data, e.g. you can push a data value (for instance std::string) from
coroutine<std::string>::push_type to coroutine<std::string>::pull_type.
if you create push_type or pull_type the framework automatically create the
counterpart for you and passes the instance to the coroutine-fn:

void coro_fn1( coroutine<std::string>::pull_type & c) {
  std::string s = c.get();

coroutine<std::string>::push_type c( coro_fn1);
std::string abc("abc");


void coro_fn2( coroutine<std::string>::push_type & c) {
  std::string xyz("xyz");
  c( xyz);

coroutine<std::string>::pull_type c( coro_fn2);
while ( c) {
  std::string s = c.get();

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at