|
Boost Users : |
Subject: Re: [Boost-users] Boost.Coroutine and Object Inheritance
From: Carlos Ferreira (carlosmf.pt_at_[hidden])
Date: 2013-12-19 19:37:00
>
> 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
How can the yield command be use, if it is not passed as an argument, like
in the echo_server example?
I dissected the echo_server example and I think I'm going to be able to go
from there.
Thanks for the info!
On 19 December 2013 17:28, Oliver Kowalke <oliver.kowalke_at_[hidden]> wrote:
> 2013/12/19 Carlos Ferreira <carlosmf.pt_at_[hidden]>
>
>> 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/echo_server.cpp
>>
>> 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
> 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");
> c(abc);
>
> or
>
> 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();
> c();
> }
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
-- Carlos Miguel Ferreira Researcher at Telecommunications Institute Aveiro - Portugal Work E-mail - cmf_at_[hidden] Skype & GTalk -> carlosmf.pt_at_[hidden] LinkedIn -> http://www.linkedin.com/in/carlosmferreira
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net