I\'m trying to rewrite a project using boost::asio::spawn
coroutines. Some parts of the project cannot be changed. For example, the storage protocol library is
Great thanks to free_coffe i managed this to work. Posting solution for my case, possibly someone need it.
template
RequestResult async_foo(Packet &pkt, CompletionToken&& token) {
typename boost::asio::handler_type< CompletionToken, void(RequestResult) >::type handler( std::forward(token) );
boost::asio::async_result result(handler);
storage_api->writePacket(pkt, handler);
return result.get();
}
Later we can use this proxy:
RequestResult res = async_foo(pkt, std::forward(yield) );