I try to wait on a std::future object which is returned from any boost::asio::async_ function (with using use_future). For example:
auto endpoint_future = resolver.async_resolve(query, boost::asio::use_future);
endpoint_future.wait(); // lasts forever after io_service.stop();
This is done in one thread. I have also another thread which is started before this async_resolve call:
runner_ = std::thread([this]() {
    boost::asio::io_service::work work(io_service_);
    io_service_.run();
});
Everything works pretty fine but later I also added a boost::asio::deadline_timer to stop any work with io_service:
void deadlineTimeout() {
    deadline_.cancel();
    io_service_.stop();
    // closing socket here does not work too
}
However, in deadlineTimeout() when deadline reaches it's timeout and it performs io_service_.stop() the future is not getting released so the endpointer_future.wait() still blocks. How can I stop waiting on the future in this case?
Aucun commentaire:
Enregistrer un commentaire