mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 14:54:32 +02:00
Rename to write_buffer_size
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
* Make value optional in param-list
|
||||
* Frame processing routines are member functions
|
||||
|
||||
API Changes:
|
||||
|
||||
* Rename mask_buffer_size to write_buffer_size
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
1.0.0-b15
|
||||
|
@@ -94,11 +94,11 @@
|
||||
<member><link linkend="beast.ref.websocket__auto_fragment_size">auto_fragment_size</link></member>
|
||||
<member><link linkend="beast.ref.websocket__decorate">decorate</link></member>
|
||||
<member><link linkend="beast.ref.websocket__keep_alive">keep_alive</link></member>
|
||||
<member><link linkend="beast.ref.websocket__mask_buffer_size">mask_buffer_size</link></member>
|
||||
<member><link linkend="beast.ref.websocket__message_type">message_type</link></member>
|
||||
<member><link linkend="beast.ref.websocket__pong_callback">pong_callback</link></member>
|
||||
<member><link linkend="beast.ref.websocket__read_buffer_size">read_buffer_size</link></member>
|
||||
<member><link linkend="beast.ref.websocket__read_message_max">read_message_max</link></member>
|
||||
<member><link linkend="beast.ref.websocket__write_buffer_size">write_buffer_size</link></member>
|
||||
</simplelist>
|
||||
</entry>
|
||||
<entry valign="top">
|
||||
|
@@ -77,7 +77,7 @@ protected:
|
||||
16 * 1024 * 1024; // max message size
|
||||
std::size_t
|
||||
wr_frag_size_ = 16 * 1024; // size of auto-fragments
|
||||
std::size_t mask_buf_size_ = 4096; // mask buffer size
|
||||
std::size_t wr_buf_size_ = 4096; // mask buffer size
|
||||
opcode wr_opcode_ = opcode::text; // outgoing message type
|
||||
pong_cb pong_cb_; // pong callback
|
||||
role_type role_; // server or client
|
||||
|
@@ -695,7 +695,7 @@ write_frame(bool fin, ConstBufferSequence const& bs, error_code& ec)
|
||||
detail::prepared_key_type key;
|
||||
detail::prepare_key(key, fh.key);
|
||||
auto const tmp_size =
|
||||
detail::clamp(fh.len, mask_buf_size_);
|
||||
detail::clamp(fh.len, wr_buf_size_);
|
||||
std::unique_ptr<std::uint8_t[]> up(
|
||||
new std::uint8_t[tmp_size]);
|
||||
std::uint64_t remain = fh.len;
|
||||
|
@@ -67,7 +67,7 @@ class stream<NextLayer>::write_frame_op
|
||||
fh.key = ws.maskgen_();
|
||||
detail::prepare_key(key, fh.key);
|
||||
tmp_size = detail::clamp(
|
||||
fh.len, ws.mask_buf_size_);
|
||||
fh.len, ws.wr_buf_size_);
|
||||
tmp = boost_asio_handler_alloc_helpers::
|
||||
allocate(tmp_size, h);
|
||||
remain = fh.len;
|
||||
|
@@ -149,45 +149,6 @@ struct keep_alive
|
||||
};
|
||||
#endif
|
||||
|
||||
/** Mask buffer size option.
|
||||
|
||||
Sets the size of the buffer allocated when the implementation
|
||||
must allocate memory to apply the mask to a payload. Only affects
|
||||
streams operating in the client role, since only clients send
|
||||
masked frames. Lowering the size of the buffer can decrease the
|
||||
memory requirements for each connection, while increasing the size
|
||||
of the buffer can reduce the number of calls made to the next
|
||||
layer to write masked data.
|
||||
|
||||
The default setting is 4096. The minimum value is 1.
|
||||
|
||||
@note Objects of this type are passed to @ref stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the write buffer size.
|
||||
@code
|
||||
...
|
||||
websocket::stream<ip::tcp::socket> ws(ios);
|
||||
ws.set_option(mask_buffer_size{8192});
|
||||
@endcode
|
||||
*/
|
||||
#if GENERATING_DOCS
|
||||
using mask_buffer_size = implementation_defined;
|
||||
#else
|
||||
struct mask_buffer_size
|
||||
{
|
||||
std::size_t value;
|
||||
|
||||
explicit
|
||||
mask_buffer_size(std::size_t n)
|
||||
: value(n)
|
||||
{
|
||||
if(n == 0)
|
||||
throw std::domain_error("invalid mask buffer size");
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** Message type option.
|
||||
|
||||
This controls the opcode set for outgoing messages. Valid
|
||||
@@ -337,6 +298,46 @@ struct read_message_max
|
||||
};
|
||||
#endif
|
||||
|
||||
/** Write buffer size option.
|
||||
|
||||
Sets the size of the write buffer used by the implementation to
|
||||
send frames. The write buffer is needed when masking payload data
|
||||
in the client role, compressing frames, or auto-fragmenting message
|
||||
data.
|
||||
|
||||
Lowering the size of the buffer can decrease the memory requirements
|
||||
for each connection, while increasing the size of the buffer can reduce
|
||||
the number of calls made to the next layer to write data.
|
||||
|
||||
The default setting is 4096. The minimum value is 64.
|
||||
|
||||
@note Objects of this type are passed to @ref stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the write buffer size.
|
||||
@code
|
||||
...
|
||||
websocket::stream<ip::tcp::socket> ws(ios);
|
||||
ws.set_option(write_buffer_size{8192});
|
||||
@endcode
|
||||
*/
|
||||
#if GENERATING_DOCS
|
||||
using write_buffer_size = implementation_defined;
|
||||
#else
|
||||
struct write_buffer_size
|
||||
{
|
||||
std::size_t value;
|
||||
|
||||
explicit
|
||||
write_buffer_size(std::size_t n)
|
||||
: value(n)
|
||||
{
|
||||
if(n < 64)
|
||||
throw std::domain_error("write buffer size is too small");
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // websocket
|
||||
} // beast
|
||||
|
||||
|
@@ -241,9 +241,9 @@ public:
|
||||
|
||||
/// Set the size of the mask buffer
|
||||
void
|
||||
set_option(mask_buffer_size const& o)
|
||||
set_option(write_buffer_size const& o)
|
||||
{
|
||||
mask_buf_size_ = o.value;
|
||||
wr_buf_size_ = o.value;
|
||||
stream_.capacity(o.value);
|
||||
}
|
||||
|
||||
|
@@ -152,13 +152,13 @@ public:
|
||||
ws.set_option(auto_fragment_size{2048});
|
||||
ws.set_option(decorate(identity{}));
|
||||
ws.set_option(keep_alive{false});
|
||||
ws.set_option(mask_buffer_size(2048));
|
||||
ws.set_option(write_buffer_size{2048});
|
||||
ws.set_option(message_type{opcode::text});
|
||||
ws.set_option(read_buffer_size(8192));
|
||||
ws.set_option(read_message_max(1 * 1024 * 1024));
|
||||
ws.set_option(read_buffer_size{8192});
|
||||
ws.set_option(read_message_max{1 * 1024 * 1024});
|
||||
try
|
||||
{
|
||||
ws.set_option(mask_buffer_size(0));
|
||||
ws.set_option(write_buffer_size{0});
|
||||
fail();
|
||||
}
|
||||
catch(std::exception const&)
|
||||
@@ -925,7 +925,7 @@ public:
|
||||
// send message with write buffer limit
|
||||
{
|
||||
std::string s(2000, '*');
|
||||
ws.set_option(mask_buffer_size(1200));
|
||||
ws.set_option(write_buffer_size(1200));
|
||||
ws.write(buffer(s.data(), s.size()));
|
||||
{
|
||||
// receive echoed message
|
||||
@@ -1187,7 +1187,7 @@ public:
|
||||
// send message with mask buffer limit
|
||||
{
|
||||
std::string s(2000, '*');
|
||||
ws.set_option(mask_buffer_size(1200));
|
||||
ws.set_option(write_buffer_size(1200));
|
||||
ws.async_write(buffer(s.data(), s.size()), do_yield[ec]);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
|
Reference in New Issue
Block a user