<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-family:arial,sans-serif;font-size:13px">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</span></blockquote>

<div>How can the yield command be use, if it is not passed as an argument, like in the echo_server example?<br><br>I dissected the echo_server example and I think I&#39;m going to be able to go from there.<br><br>Thanks for the info!</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 19 December 2013 17:28, Oliver Kowalke <span dir="ltr">&lt;<a href="mailto:oliver.kowalke@gmail.com" target="_blank">oliver.kowalke@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">2013/12/19 Carlos Ferreira <span dir="ltr">&lt;<a href="mailto:carlosmf.pt@gmail.com" target="_blank">carlosmf.pt@gmail.com</a>&gt;</span><div class="gmail_extra">

<div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<span style="font-family:arial,sans-serif;font-size:11px">1.) do you know that boost.asio integrates boost.coroutine? example can be read at�</span><a href="http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/example/cpp03/spawn/echo_server.cpp" style="font-family:arial,sans-serif;font-size:11px" target="_blank">http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/example/cpp03/spawn/echo_server.cpp</a></blockquote>




</div><div>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.</div>


</div></blockquote></div><div><br><pre>boost::asio::spawn(io_service,
        boost::bind(do_accept,
          boost::ref(io_service), atoi(argv[1]), _1));</pre><br></div><div>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<br>


</div><div class="im"><div>�</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>

<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-family:arial,sans-serif;font-size:11px">2.) coroutine&lt;&gt; is a type holder, e.g. you have to derive from coroutine&lt;&gt;::push_type or coroutine&lt;&gt;::pull_type</span></blockquote>




</div><div>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?</div></div></blockquote><div><br></div></div><div>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&lt;std::string&gt;::push_type to coroutine&lt;std::string&gt;::pull_type.<br>


</div><div>if you create push_type or pull_type the framework automatically create the counterpart for you and passes the instance to the coroutine-fn:<br><br></div><div>void coro_fn1( coroutine&lt;std::string&gt;::pull_type &amp; c) {<br>


</div><div>� std::string s = c.get();<br>}<br><br></div><div>coroutine&lt;std::string&gt;::push_type c( coro_fn1);<br></div><div>std::string abc(&quot;abc&quot;);<br></div><div>c(abc);<br><br></div><div>or<br><br><div>void coro_fn2( coroutine&lt;std::string&gt;::push_type &amp; c) {<br>


</div><div>� std::string xyz(&quot;xyz&quot;);<br></div><div>� c( xyz);<br></div><div>}<br><br></div><div>coroutine&lt;std::string&gt;::pull_type c( coro_fn2);<br></div><div>while ( c) {<br></div>� std::string s = c.get();<br>


</div><div>� c();<br></div><div>}<br></div></div><br></div></div>
<br>_______________________________________________<br>
Boost-users mailing list<br>
<a href="mailto:Boost-users@lists.boost.org">Boost-users@lists.boost.org</a><br>
<a href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" target="_blank">http://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">

<div><br></div><div>Carlos Miguel Ferreira</div><div>Researcher at Telecommunications Institute</div><div>Aveiro - Portugal</div><div>Work E-mail - <a href="mailto:cmf@av.it.pt" target="_blank">cmf@av.it.pt</a></div><div>

Skype &amp; GTalk -&gt; <a href="http://carlosmf.pt" target="_blank">carlosmf.pt</a>@<a href="http://gmail.com" target="_blank">gmail.com</a></div><div>LinkedIn -&gt;�<a href="http://www.linkedin.com/in/carlosmferreira" target="_blank">http://www.linkedin.com/in/carlosmferreira</a></div>

</div>
</div>