Opened 9 years ago
Closed 8 years ago
#9442 closed Bugs (fixed)
boost::asio::spawn does nothing when coroutines v2 are enabled
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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.
#include <iostream> #include <functional> //#define BOOST_COROUTINES_UNIDIRECT //#define BOOST_COROUTINES_V2 #include <boost/asio.hpp> #include <boost/asio/spawn.hpp> void foo(boost::asio::yield_context ctx) { std::cout << "works!" << std::endl; } int main() { boost::asio::io_service srv; boost::asio::spawn(srv, std::bind(foo, std::placeholders::_1)); srv.run(); }
I am not sure if asio is intentionally not using new coroutines interface by default, but this seems pretty important thing going forward.
Change History (3)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
It is typo here in asio code:
#elif defined(BOOST_COROUTINES_UNIDRECT) ...
should be
#elif defined(BOOST_COROUTINES_UNIDIRECT) ...
comment:3 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed on 'develop' in 85640f548a6e0934fc3103ccf8643c5c6eaed960.
Merged to 'master' in 4e1e7d731fcc5c0104567856de476f7ce8806d72.
this is my fix on top of boost 1.55.0:
not entirely sure it'll work, but it definitely seems to