mirror of
https://github.com/boostorg/beast.git
synced 2025-08-02 22:34:32 +02:00
Limit the number of net::async_write instantiations by using a common buffer sequence type
closes #2169
This commit is contained in:
committed by
Richard Hodges
parent
c20746e6a7
commit
760b875c3b
@@ -1,3 +1,4 @@
|
|||||||
|
* Limit async_write instantiations in websocket ops.
|
||||||
* Add Drone CI status.
|
* Add Drone CI status.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@@ -294,7 +294,7 @@ public:
|
|||||||
"websocket::async_read_some"));
|
"websocket::async_read_some"));
|
||||||
|
|
||||||
net::async_write(
|
net::async_write(
|
||||||
impl.stream(), impl.rd_fb.data(),
|
impl.stream(), net::const_buffer(impl.rd_fb.data()),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
}
|
}
|
||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
@@ -661,7 +661,7 @@ public:
|
|||||||
__FILE__, __LINE__,
|
__FILE__, __LINE__,
|
||||||
"websocket::async_read_some"));
|
"websocket::async_read_some"));
|
||||||
|
|
||||||
net::async_write(impl.stream(), impl.rd_fb.data(),
|
net::async_write(impl.stream(), net::const_buffer(impl.rd_fb.data()),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
}
|
}
|
||||||
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
BOOST_ASSERT(impl.wr_block.is_locked(this));
|
||||||
|
@@ -147,10 +147,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<class NextLayer, bool deflateSupported>
|
template<class NextLayer, bool deflateSupported>
|
||||||
template<class Buffers, class Handler>
|
template<class Handler, class Buffers>
|
||||||
void
|
void
|
||||||
stream<NextLayer, deflateSupported>::
|
stream<NextLayer, deflateSupported>::
|
||||||
write_some_op<Buffers, Handler>::
|
write_some_op<Handler, Buffers>::
|
||||||
operator()(
|
operator()(
|
||||||
error_code ec,
|
error_code ec,
|
||||||
std::size_t bytes_transferred,
|
std::size_t bytes_transferred,
|
||||||
@@ -222,7 +222,12 @@ operator()(
|
|||||||
));
|
));
|
||||||
|
|
||||||
net::async_write(impl.stream(),
|
net::async_write(impl.stream(),
|
||||||
buffers_cat(impl.wr_fb.data(), cb_),
|
buffers_cat(
|
||||||
|
net::const_buffer(impl.wr_fb.data()),
|
||||||
|
net::const_buffer(0, 0),
|
||||||
|
cb_,
|
||||||
|
buffers_prefix(0, cb_)
|
||||||
|
),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
}
|
}
|
||||||
bytes_transferred_ += clamp(fh_.len);
|
bytes_transferred_ += clamp(fh_.len);
|
||||||
@@ -256,9 +261,16 @@ operator()(
|
|||||||
"websocket::async_write_some"
|
"websocket::async_write_some"
|
||||||
));
|
));
|
||||||
|
|
||||||
net::async_write(impl.stream(), buffers_cat(
|
buffers_suffix<Buffers> empty_cb(cb_);
|
||||||
impl.wr_fb.data(),
|
empty_cb.consume(~std::size_t(0));
|
||||||
buffers_prefix(clamp(fh_.len), cb_)),
|
|
||||||
|
net::async_write(impl.stream(),
|
||||||
|
buffers_cat(
|
||||||
|
net::const_buffer(impl.wr_fb.data()),
|
||||||
|
net::const_buffer(0, 0),
|
||||||
|
empty_cb,
|
||||||
|
buffers_prefix(clamp(fh_.len), cb_)
|
||||||
|
),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
}
|
}
|
||||||
n = clamp(fh_.len); // restore `n` on yield
|
n = clamp(fh_.len); // restore `n` on yield
|
||||||
@@ -316,9 +328,16 @@ operator()(
|
|||||||
"websocket::async_write_some"
|
"websocket::async_write_some"
|
||||||
));
|
));
|
||||||
|
|
||||||
net::async_write(impl.stream(), buffers_cat(
|
buffers_suffix<Buffers> empty_cb(cb_);
|
||||||
impl.wr_fb.data(),
|
empty_cb.consume(~std::size_t(0));
|
||||||
net::buffer(impl.wr_buf.get(), n)),
|
|
||||||
|
net::async_write(impl.stream(),
|
||||||
|
buffers_cat(
|
||||||
|
net::const_buffer(impl.wr_fb.data()),
|
||||||
|
net::const_buffer(net::buffer(impl.wr_buf.get(), n)),
|
||||||
|
empty_cb,
|
||||||
|
buffers_prefix(0, empty_cb)
|
||||||
|
),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
}
|
}
|
||||||
// VFALCO What about consuming the buffer on error?
|
// VFALCO What about consuming the buffer on error?
|
||||||
@@ -345,8 +364,16 @@ operator()(
|
|||||||
"websocket::async_write_some"
|
"websocket::async_write_some"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
buffers_suffix<Buffers> empty_cb(cb_);
|
||||||
|
empty_cb.consume(~std::size_t(0));
|
||||||
|
|
||||||
net::async_write(impl.stream(),
|
net::async_write(impl.stream(),
|
||||||
net::buffer(impl.wr_buf.get(), n),
|
buffers_cat(
|
||||||
|
net::const_buffer(0, 0),
|
||||||
|
net::const_buffer(net::buffer(impl.wr_buf.get(), n)),
|
||||||
|
empty_cb,
|
||||||
|
buffers_prefix(0, empty_cb)
|
||||||
|
),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
}
|
}
|
||||||
bytes_transferred_ += bytes_transferred;
|
bytes_transferred_ += bytes_transferred;
|
||||||
@@ -387,9 +414,16 @@ operator()(
|
|||||||
"websocket::async_write_some"
|
"websocket::async_write_some"
|
||||||
));
|
));
|
||||||
|
|
||||||
net::async_write(impl.stream(), buffers_cat(
|
buffers_suffix<Buffers> empty_cb(cb_);
|
||||||
impl.wr_fb.data(),
|
empty_cb.consume(~std::size_t(0));
|
||||||
net::buffer(impl.wr_buf.get(), n)),
|
|
||||||
|
net::async_write(impl.stream(),
|
||||||
|
buffers_cat(
|
||||||
|
net::const_buffer(impl.wr_fb.data()),
|
||||||
|
net::const_buffer(net::buffer(impl.wr_buf.get(), n)),
|
||||||
|
empty_cb,
|
||||||
|
buffers_prefix(0, empty_cb)
|
||||||
|
),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
}
|
}
|
||||||
n = bytes_transferred - impl.wr_fb.size();
|
n = bytes_transferred - impl.wr_fb.size();
|
||||||
@@ -460,8 +494,16 @@ operator()(
|
|||||||
"websocket::async_write_some"
|
"websocket::async_write_some"
|
||||||
));
|
));
|
||||||
|
|
||||||
net::async_write(impl.stream(), buffers_cat(
|
buffers_suffix<Buffers> empty_cb(cb_);
|
||||||
impl.wr_fb.data(), b),
|
empty_cb.consume(~std::size_t(0));
|
||||||
|
|
||||||
|
net::async_write(impl.stream(),
|
||||||
|
buffers_cat(
|
||||||
|
net::const_buffer(impl.wr_fb.data()),
|
||||||
|
net::const_buffer(b),
|
||||||
|
empty_cb,
|
||||||
|
buffers_prefix(0, empty_cb)
|
||||||
|
),
|
||||||
beast::detail::bind_continuation(std::move(*this)));
|
beast::detail::bind_continuation(std::move(*this)));
|
||||||
}
|
}
|
||||||
bytes_transferred_ += in_;
|
bytes_transferred_ += in_;
|
||||||
|
Reference in New Issue
Block a user