Suppose when calling io_service::run(), there are multiple async_read operations scheduled (There may be other operations in between them). What happens when an asynchronous operation like async_write is scheduled in the ReadHandler-function?
void handler(const boost::system::error_code& error, std::size_t bytes) {
async_write(sock, boost::asio::buffer(wbuf), whandler);
}
That is, when will the async_write be invoked? I would expect the order of execution to be:
1) async_read //1
2) async_write
3) async_read //2
4) async_write
Is this order of execution guaranteed?