Open rodgert opened 9 years ago
AFAIK, std::future support was added to ASIO in Boost 1.55. But I'm not 100% sure.
I can confirm with Chris Kohlhoff, but I was thinking of just making 1.56 the base Boost required version unless there is a compelling reason not to.
On Sunday, November 23, 2014, Andrey Upadyshev notifications@github.com wrote:
AFAIK, std::future support was added to ASIO in Boost 1.55. But I'm not 100% sure.
— Reply to this email directly or view it on GitHub https://github.com/zeromq/aziomq/issues/11#issuecomment-64142397.
Chris confirms 1.54 introduced std::future support. I'm happy to make that the minimum version if there is a compelling reason.
On Sunday, November 23, 2014, Thomas Rodgers rodgert@twrodgers.com wrote:
I can confirm with Chris Kohlhoff, but I was thinking of just making 1.56 the base Boost required version unless there is a compelling reason not to.
On Sunday, November 23, 2014, Andrey Upadyshev <notifications@github.com javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:
AFAIK, std::future support was added to ASIO in Boost 1.55. But I'm not 100% sure.
— Reply to this email directly or view it on GitHub https://github.com/zeromq/aziomq/issues/11#issuecomment-64142397.
Yes please. It's better to keep minimum Boost version as low as possible because many companies too cautious to upgrade it often.
In case you guys are still looking for a solution, this is what I use (inside a util
namespace):
template<class T, class ConstBufferSequence, class CompletionToken>
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken,
void(boost::system::error_code, std::size_t))
async_send(T &socket, const ConstBufferSequence& buffers,
CompletionToken &&token)
{
boost::asio::async_completion<
CompletionToken, void(boost::system::error_code, std::size_t)
> init{token};
socket.async_send(
buffers,
[handler=std::move(init.completion_handler)](
const boost::system::error_code &ec, std::size_t bytes_transferred
) mutable {
handler.get_executor().dispatch(
[ec,bytes_transferred,handler]() mutable {
handler(ec, bytes_transferred);
}, std::allocator<void>{}
);
}
);
return init.result.get();
}
handler.get_executor()
can be replaced with get_associated_executor(handler, socket.get_executor())
if you handler doesn't always have an associated executor.
Newer versions of Asio implement an extensible async_ form that allows async operations to work with std::future, among other things.
Will require bumping the minimum version of boost to 1.56 or later