Fix all async initiating functions with use_awaitable:

Add trait:
    is_completion_token_for

Fixes for
    buffered_read_stream

Add tests for
    basic_stream
    buffered_read_stream
    flat_stream
    http (all)
    websocket (all)

resolves #1920
This commit is contained in:
Richard Hodges
2020-04-28 20:48:00 +02:00
parent 24cc4a7aee
commit d016ff52af
14 changed files with 382 additions and 6 deletions
+59
View File
@@ -26,6 +26,9 @@
#include <boost/asio/strand.hpp>
#include <sstream>
#include <string>
#if BOOST_ASIO_HAS_CO_AWAIT
#include <boost/asio/use_awaitable.hpp>
#endif
namespace boost {
namespace beast {
@@ -994,6 +997,59 @@ public:
}
}
#if BOOST_ASIO_HAS_CO_AWAIT
void testAwaitableCompiles(
test::stream& stream,
serializer<true, string_body>& request_serializer,
request<string_body>& req,
request<string_body> const& creq,
serializer<false, string_body>& response_serializer,
response<string_body>& resp,
response<string_body> const& cresp)
{
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write(stream, request_serializer, net::use_awaitable))>);
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write(stream, response_serializer, net::use_awaitable))>);
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write(stream, req, net::use_awaitable))>);
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write(stream, creq, net::use_awaitable))>);
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write(stream, resp, net::use_awaitable))>);
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write(stream, cresp, net::use_awaitable))>);
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write_some(stream, request_serializer, net::use_awaitable))>);
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write_some(stream, response_serializer, net::use_awaitable))>);
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write_header(stream, request_serializer, net::use_awaitable))>);
static_assert(std::is_same_v<
net::awaitable<std::size_t>, decltype(
http::async_write_header(stream, response_serializer, net::use_awaitable))>);
}
#endif
void
run() override
{
@@ -1017,6 +1073,9 @@ public:
});
testAsioHandlerInvoke();
testBodyWriters();
#if BOOST_ASIO_HAS_CO_AWAIT
boost::ignore_unused(&write_test::testAwaitableCompiles);
#endif
}
};