forked from boostorg/beast
@@ -1,6 +1,7 @@
|
|||||||
Version 209:
|
Version 209:
|
||||||
|
|
||||||
* Faster http::string_to_field
|
* Faster http::string_to_field
|
||||||
|
* async_echo supports move-only handlers
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -277,7 +277,7 @@ async_echo(AsyncStream& stream, CompletionToken&& token)
|
|||||||
BOOST_ASIO_HANDLER_TYPE(
|
BOOST_ASIO_HANDLER_TYPE(
|
||||||
CompletionToken, void(boost::beast::error_code))>{
|
CompletionToken, void(boost::beast::error_code))>{
|
||||||
stream,
|
stream,
|
||||||
init.completion_handler}(boost::beast::error_code{}, 0);
|
std::move(init.completion_handler)}({}, 0);
|
||||||
|
|
||||||
// This hook lets the caller see a return value when appropriate.
|
// This hook lets the caller see a return value when appropriate.
|
||||||
// For example this might return std::future<error_code> if
|
// For example this might return std::future<error_code> if
|
||||||
@@ -289,6 +289,18 @@ async_echo(AsyncStream& stream, CompletionToken&& token)
|
|||||||
|
|
||||||
//]
|
//]
|
||||||
|
|
||||||
|
struct move_only_handler
|
||||||
|
{
|
||||||
|
move_only_handler(move_only_handler&&) = default;
|
||||||
|
move_only_handler(move_only_handler const&) = delete;
|
||||||
|
|
||||||
|
void operator()(boost::beast::error_code ec)
|
||||||
|
{
|
||||||
|
if(ec)
|
||||||
|
std::cerr << ": " << ec.message() << std::endl;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if(argc != 3)
|
if(argc != 3)
|
||||||
@@ -317,12 +329,7 @@ int main(int argc, char** argv)
|
|||||||
acceptor.bind(ep);
|
acceptor.bind(ep);
|
||||||
acceptor.listen();
|
acceptor.listen();
|
||||||
acceptor.accept(sock);
|
acceptor.accept(sock);
|
||||||
async_echo(sock,
|
async_echo(sock, move_only_handler{});
|
||||||
[&](boost::beast::error_code ec)
|
|
||||||
{
|
|
||||||
if(ec)
|
|
||||||
std::cerr << argv[0] << ": " << ec.message() << std::endl;
|
|
||||||
});
|
|
||||||
ioc.run();
|
ioc.run();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user