Opened 5 years ago
Last modified 5 years ago
#13337 new Bugs
io_service::stop() behavior on MSVC contradicts documentation
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost 1.63.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The io_service::stop() documentation says:
[...] All invocations of this run() or run_one() member functions should return as soon as possible [...]
This is the behavior observed on GCC but not on MSVC.
Reproducer code:
#include <boost/asio.hpp> #include <thread> #include <iostream> using namespace std::chrono_literals; int main() { boost::asio::io_service s; s.post([] { std::this_thread::sleep_for(5ms); std::cout << "1\n"; }); s.post([] { std::this_thread::sleep_for(5ms); std::cout << "2\n"; }); s.post([] { std::this_thread::sleep_for(5ms); std::cout << "3\n"; }); std::thread th([&] { s.run(); }); std::this_thread::sleep_for(1ms); s.stop(); th.join(); }
This prints "1" on GCC but "1 2 3" on MSVC
This bug was concretized by an Stack Overflow user while he investigated #13317. See his answer for more information.
Note:
See TracTickets
for help on using tickets.
Select the correct boost component