Suppose I have a library that allows to make asynchronous requests and returns a std::future
to query the (state of the) result. I want to integrate that library with a boost::asio::io_service
so that a callback is called in the io_service
loop as soon as the future is ready. Is there any way to achieve that without changing the library or regularly polling the future in the io loop?
Note: there are several questions that deal with the reverse problem, i.e. getting a std::future
that is ready when some operation on the io_service
completes (e.g. Program to read asynchronously in boost asio with C++11 future). I couldn't find a way of achieving the exact opposite, i.e. getting a callback executed on the io_service
when the future
is ready.