Created
February 20, 2019 08:05
-
-
Save HungMingWu/75bef528561d27d5f936728dcbabf2ed to your computer and use it in GitHub Desktop.
Write my own custom asio async function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/system/error_code.hpp> | |
#include <boost/asio/async_result.hpp> | |
#include <boost/asio/detail/handler_type_requirements.hpp> | |
template< | |
class ReadHandler> | |
BOOST_ASIO_INITFN_RESULT_TYPE( | |
ReadHandler, void(boost::system::error_code, std::size_t)) | |
async_read(ReadHandler&& handler) | |
{ | |
// If you get an error on the following line it means that your handler does | |
// not meet the documented type requirements for a ReadHandler. | |
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; | |
boost::asio::async_completion<ReadHandler, | |
void(boost::system::error_code, std::size_t)> init(handler); | |
return init.result.get(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment