Does anyone have a good pointer to examples which use futures from the Boost thread library with Boost ASIO? I have an existing asynchronous library which uses callback function
Can you please look at this example:
http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/example/cpp11/futures/daytime_client.cpp
It shows how to use std::future
with boost asio.
The key point is to include file use_future.hpp
:
#include
Then you can write code like that:
std::future my_future =
my_socket.async_read_some(my_buffer, boost::asio::use_future);
If you need to use boost::future
then I'd suggest to implement another variant, similar to boost::asio::use_future
.
The file use_future.hpp
is a good example for that.