forked from boostorg/beast
Remove BodyReader::is_deferred (API Change):
The is_deferred nested type is removed from the BodyReader requirements. Performance for sending messages with `file_body` was cut almost in half with is_deferred as `std::true_type` since it caused double the number of socket writes. If the deferred behavior is absolutely necessary, callers can get the same effect by manually sending the headers first. Actions Required: * Callers who need the behavior of is_deferred as `std::true_type` should manually construct a serializer and serialize the header first, followed by the body.
This commit is contained in:
1 parent
bf59634bc2
commit
edeb44617b
12 files changed
+24
-86
No files matched your search
@@ -96,8 +96,6 @@ struct buffer_body
|
||||
value_type const& body_;
|
||||
|
||||
public:
|
||||
using is_deferred = std::false_type;
|
||||
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffers_1;
|
||||
|
||||
|
||||
@@ -45,8 +45,6 @@ struct basic_dynamic_body
|
||||
DynamicBuffer const& body_;
|
||||
|
||||
public:
|
||||
using is_deferred = std::false_type;
|
||||
|
||||
using const_buffers_type =
|
||||
typename DynamicBuffer::const_buffers_type;
|
||||
|
||||
|
||||
@@ -49,8 +49,6 @@ struct empty_body
|
||||
#else
|
||||
struct reader
|
||||
{
|
||||
using is_deferred = std::false_type;
|
||||
|
||||
using const_buffers_type =
|
||||
boost::asio::null_buffers;
|
||||
|
||||
|
||||
@@ -74,12 +74,10 @@ get(error_code& ec, Visit&& visit)
|
||||
if(ec)
|
||||
return;
|
||||
auto result = rd_->get(ec);
|
||||
if(ec == error::need_more)
|
||||
goto go_header_only;
|
||||
if(ec)
|
||||
{
|
||||
// Can't use need_more when ! is_deferred
|
||||
BOOST_ASSERT(ec != error::need_more);
|
||||
return;
|
||||
}
|
||||
if(! result)
|
||||
goto go_header_only;
|
||||
more_ = result->second;
|
||||
@@ -103,10 +101,12 @@ get(error_code& ec, Visit&& visit)
|
||||
break;
|
||||
|
||||
case do_body:
|
||||
BOOST_ASSERT(! rd_);
|
||||
rd_.emplace(m_, ec);
|
||||
if(ec)
|
||||
return;
|
||||
if(! rd_)
|
||||
{
|
||||
rd_.emplace(m_, ec);
|
||||
if(ec)
|
||||
return;
|
||||
}
|
||||
s_ = do_body + 1;
|
||||
BOOST_FALLTHROUGH;
|
||||
|
||||
@@ -139,12 +139,10 @@ get(error_code& ec, Visit&& visit)
|
||||
if(ec)
|
||||
return;
|
||||
auto result = rd_->get(ec);
|
||||
if(ec == error::need_more)
|
||||
goto go_header_only_c;
|
||||
if(ec)
|
||||
{
|
||||
// Can't use need_more when ! is_deferred
|
||||
BOOST_ASSERT(ec != error::need_more);
|
||||
return;
|
||||
}
|
||||
if(! result)
|
||||
goto go_header_only_c;
|
||||
more_ = result->second;
|
||||
@@ -179,10 +177,12 @@ get(error_code& ec, Visit&& visit)
|
||||
break;
|
||||
|
||||
case do_body_c:
|
||||
BOOST_ASSERT(! rd_);
|
||||
rd_.emplace(m_, ec);
|
||||
if(ec)
|
||||
return;
|
||||
if(! rd_)
|
||||
{
|
||||
rd_.emplace(m_, ec);
|
||||
if(ec)
|
||||
return;
|
||||
}
|
||||
s_ = do_body_c + 1;
|
||||
BOOST_FALLTHROUGH;
|
||||
|
||||
|
||||
@@ -144,16 +144,11 @@ class serializer
|
||||
do_complete = 110
|
||||
};
|
||||
|
||||
void split(bool, std::true_type) {}
|
||||
void split(bool v, std::false_type) { split_ = v; }
|
||||
void frdinit(std::true_type);
|
||||
void frdinit(std::false_type);
|
||||
|
||||
using reader = typename Body::reader;
|
||||
|
||||
using is_deferred =
|
||||
typename reader::is_deferred;
|
||||
|
||||
using ch_t = consuming_buffers<typename
|
||||
Fields::reader::const_buffers_type>; // header
|
||||
|
||||
@@ -190,7 +185,7 @@ class serializer
|
||||
boost::variant<boost::blank,
|
||||
ch_t, cb0_t, cb1_t, ch0_t, ch1_t, ch2_t> v_;
|
||||
int s_ = do_construct;
|
||||
bool split_ = is_deferred::value;
|
||||
bool split_ = false;
|
||||
bool header_done_ = false;
|
||||
bool chunked_;
|
||||
bool close_;
|
||||
@@ -227,14 +222,12 @@ public:
|
||||
When the split feature is enabled, the implementation will
|
||||
write only the octets corresponding to the serialized header
|
||||
first. If the header has already been written, this function
|
||||
will have no effect on output. This function should be called
|
||||
before retrieving any buffers using @ref get, otherwise the
|
||||
behavior is undefined.
|
||||
will have no effect on output.
|
||||
*/
|
||||
void
|
||||
split(bool v)
|
||||
{
|
||||
split(v, is_deferred{});
|
||||
split_ = v;
|
||||
}
|
||||
|
||||
/** Return `true` if serialization of the header is complete.
|
||||
|
||||
@@ -47,8 +47,6 @@ struct string_body
|
||||
value_type const& body_;
|
||||
|
||||
public:
|
||||
using is_deferred = std::false_type;
|
||||
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffers_1;
|
||||
|
||||
|
||||
@@ -48,8 +48,6 @@ struct string_view_body
|
||||
string_view body_;
|
||||
|
||||
public:
|
||||
using is_deferred = std::false_type;
|
||||
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffers_1;
|
||||
|
||||
|
||||
Reference in new issue
Block a user