Boost C++ Libraries: Ticket #9442: boost::asio::spawn does nothing when coroutines v2 are enabled https://svn.boost.org/trac10/ticket/9442 <p> Following code works as expected (i.e. prints 'works'). However, it prints nothing if you uncomment lines that enable (or try to enable) use of coroutines v2 in spawn. </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;functional&gt; //#define BOOST_COROUTINES_UNIDIRECT //#define BOOST_COROUTINES_V2 #include &lt;boost/asio.hpp&gt; #include &lt;boost/asio/spawn.hpp&gt; void foo(boost::asio::yield_context ctx) { std::cout &lt;&lt; "works!" &lt;&lt; std::endl; } int main() { boost::asio::io_service srv; boost::asio::spawn(srv, std::bind(foo, std::placeholders::_1)); srv.run(); } </pre><p> I am not sure if asio is intentionally not using new coroutines interface by default, but this seems pretty important thing going forward. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9442 Trac 1.4.3 drigh@… Thu, 28 Nov 2013 02:27:10 GMT <link>https://svn.boost.org/trac10/ticket/9442#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9442#comment:1</guid> <description> <p> this is my fix on top of boost 1.55.0: </p> <pre class="wiki">diff --git a/boost/asio/spawn.hpp b/boost/asio/spawn.hpp index 0d7ee77..232e2e0 100644 --- a/boost/asio/spawn.hpp +++ b/boost/asio/spawn.hpp @@ -54,12 +54,12 @@ public: * When using Boost.Coroutine v1, this type is: * @code typename coroutine&lt;void()&gt; @endcode * When using Boost.Coroutine v2 (unidirectional coroutines), this type is: - * @code push_coroutine&lt;void&gt; @endcode + * @code pull_coroutine&lt;void&gt; @endcode */ #if defined(GENERATING_DOCUMENTATION) typedef implementation_defined callee_type; #elif defined(BOOST_COROUTINES_UNIDRECT) || defined(BOOST_COROUTINES_V2) - typedef boost::coroutines::push_coroutine&lt;void&gt; callee_type; + typedef boost::coroutines::pull_coroutine&lt;void&gt; callee_type; #else typedef boost::coroutines::coroutine&lt;void()&gt; callee_type; #endif @@ -69,12 +69,12 @@ public: * When using Boost.Coroutine v1, this type is: * @code typename coroutine&lt;void()&gt;::caller_type @endcode * When using Boost.Coroutine v2 (unidirectional coroutines), this type is: - * @code pull_coroutine&lt;void&gt; @endcode + * @code push_coroutine&lt;void&gt; @endcode */ #if defined(GENERATING_DOCUMENTATION) typedef implementation_defined caller_type; #elif defined(BOOST_COROUTINES_UNIDRECT) || defined(BOOST_COROUTINES_V2) - typedef boost::coroutines::pull_coroutine&lt;void&gt; caller_type; + typedef boost::coroutines::push_coroutine&lt;void&gt; caller_type; #else typedef boost::coroutines::coroutine&lt;void()&gt;::caller_type caller_type; #endif </pre><p> not entirely sure it'll work, but it definitely seems to </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 24 Feb 2014 20:12:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9442#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9442#comment:2</guid> <description> <p> It is typo here in asio code: </p> <p> #elif defined(BOOST_COROUTINES_UNIDRECT) ... </p> <p> should be </p> <p> #elif defined(BOOST_COROUTINES_UNIDIRECT) ... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 05 May 2014 07:19:00 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9442#comment:3 https://svn.boost.org/trac10/ticket/9442#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed on 'develop' in <a class="ext-link" href="https://github.com/boostorg/asio/commit/85640f548a6e0934fc3103ccf8643c5c6eaed960"><span class="icon">​</span>85640f548a6e0934fc3103ccf8643c5c6eaed960</a>. </p> <p> Merged to 'master' in <a class="ext-link" href="https://github.com/boostorg/asio/commit/4e1e7d731fcc5c0104567856de476f7ce8806d72"><span class="icon">​</span>4e1e7d731fcc5c0104567856de476f7ce8806d72</a>. </p> Ticket