2013/12/19 Carlos Ferreira
1.) do you know that boost.asio integrates boost.coroutine? example can be
read at http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/example/cpp03/spawn...
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::asio::spawn(io_service, boost::bind(do_accept, 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 arguments
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 coroutinestd::string::push_type to coroutinestd::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( coroutinestd::string::pull_type & c) { std::string s = c.get(); } coroutinestd::string::push_type c( coro_fn1); std::string abc("abc"); c(abc); or void coro_fn2( coroutinestd::string::push_type & c) { std::string xyz("xyz"); c( xyz); } coroutinestd::string::pull_type c( coro_fn2); while ( c) { std::string s = c.get(); c(); }