boost::corosio::tcp_server::join
Block until all accept loops complete.
Synopsis
Declared in <boost/corosio/tcp_server.hpp>
void
join();
Description
Blocks the calling thread until all accept coroutines launched by start have finished executing. This synchronizes the shutdown sequence, ensuring the server is fully stopped before restarting or destroying it.
Postconditions
All accept loops have completed. The server is in the stopped state and may be restarted via start.
Example (Correct Usage)
// main thread
srv.start();
ioc.run(); // Blocks until work completes
srv.join(); // Safe: called after ioc.run() returns
WARNING: Deadlock Scenarios
Calling join() from the wrong context causes deadlock:
// WRONG: calling join() from inside a worker coroutine
void run( launcher launch ) override
{
launch( ex, [this]() -> capy::task<>
{
srv_.join(); // DEADLOCK: blocks the executor
co_return;
}());
}
// WRONG: calling join() while ioc.run() is still active
std::thread t( [&]{ ioc.run(); } );
srv.stop();
srv.join(); // DEADLOCK: ioc.run() still running in thread t
Thread Safety
May be called from any thread, but will deadlock if called from within the io_context event loop or from a worker coroutine.
See Also
stop, start
Created with MrDocs