Boost C++ Libraries: Ticket #13567: io_context ::run() doesn't return immediately on stopped io_context due to Windows implementation https://svn.boost.org/trac10/ticket/13567 <p> This code hangs, when running on Windows: </p> <pre class="wiki"> boost::asio::io_context context; // 1 boost::asio::post(context, []() { for (;;); }); // 2 context.stop(); // 3 context.run(); // hangs in a handler, posted in 2 </pre><p> <a class="ext-link" href="https://www.boost.org/doc/libs/1_67_0/doc/html/boost_asio/reference/io_context/stop.html"><span class="icon">​</span>io_context::stop</a> documentation says: </p> <blockquote> <p> Subsequent calls to run(), run_one(), poll() or poll_one() will return immediately until restart() is called. </p> </blockquote> <p> Which is, judging by example above, isn't true. Same goes for <a class="ext-link" href="https://www.boost.org/doc/libs/1_67_0/doc/html/boost_asio/reference/io_context/stopped.html"><span class="icon">​</span>io_context::stopped</a>: </p> <blockquote> <p> When an io_context object is stopped, calls to run(), run_one(), poll() or poll_one() will return immediately without invoking any handlers. </p> </blockquote> <p> and code example below: </p> <pre class="wiki"> boost::asio::io_context context; // 1 boost::asio::post(context, []() { for (;;); }); // 2 context.stop(); // 3 if (context.stopped()) { context.run(); // hangs in a handler, posted in 2 } </pre><p> When running on Linux, same code fully complies the documentation and doesn't invoke any handlers in examples provided. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13567 Trac 1.4.3