read_buffer_size is a member of stream (API Change):

fix #446

* The read_buffer_size option struct is removed

Actions Required:

* Change call sites which use read_buffer_size with set_option to
  call stream::read_buffer_size instead.
This commit is contained in:
Vinnie Falco
2017-06-08 18:12:27 -07:00
parent e6c0d698ee
commit 513a54835c
5 changed files with 46 additions and 52 deletions

View File

@@ -4,6 +4,7 @@ API Changes:
* auto_fragment is a member of stream
* binary, text are members of stream
* read_buffer_size is a member of stream
Actions Required:
@@ -13,6 +14,9 @@ Actions Required:
* Change call sites which use message_type with set_option
to call stream::binary or stream::text instead.
* Change call sites which use read_buffer_size with set_option to
call stream::read_buffer_size instead.
--------------------------------------------------------------------------------
Version 51

View File

@@ -125,7 +125,6 @@
<simplelist type="vert" columns="1">
<member><link linkend="beast.ref.websocket__permessage_deflate">permessage_deflate</link></member>
<member><link linkend="beast.ref.websocket__ping_callback">ping_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>

View File

@@ -124,47 +124,6 @@ struct ping_callback
};
#endif
/** Read buffer size option.
Sets the size of the read buffer used by the implementation to
receive frames. The read buffer is needed when permessage-deflate
is used.
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 read data.
The default setting is 4096. The minimum value is 8.
@note Objects of this type are used with
@ref beast::websocket::stream::set_option.
@par Example
Setting the read buffer size.
@code
...
websocket::stream<ip::tcp::socket> ws(ios);
ws.set_option(read_buffer_size{16 * 1024});
@endcode
*/
#if BEAST_DOXYGEN
using read_buffer_size = implementation_defined;
#else
struct read_buffer_size
{
std::size_t value;
explicit
read_buffer_size(std::size_t n)
: value(n)
{
if(n < 8)
BOOST_THROW_EXCEPTION(std::invalid_argument{
"read buffer size is too small"});
}
};
#endif
/** Maximum incoming message size option.
Sets the largest permissible incoming message size. Message

View File

@@ -263,15 +263,6 @@ public:
ping_cb_ = std::move(o.value);
}
/// Set the read buffer size
void
set_option(read_buffer_size const& o)
{
rd_buf_size_ = o.value;
// VFALCO What was the thinking here?
//stream_.capacity(o.value);
}
/// Set the maximum incoming message size allowed
void
set_option(read_message_max const& o)
@@ -331,6 +322,9 @@ public:
@code
ws.binary(true);
@endcode
@param v `true` if outgoing messages should indicate
binary, or `false` if they should indicate text.
*/
void
binary(bool v)
@@ -345,6 +339,44 @@ public:
return wr_opcode_ == opcode::binary;
}
/** Set the read buffer size option.
Sets the size of the read buffer used by the implementation to
receive frames. The read buffer is needed when permessage-deflate
is used.
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 read data.
The default setting is 4096. The minimum value is 8.
@par Example
Setting the read buffer size.
@code
ws.read_buffer_size(16 * 1024);
@endcode
@param n The size of the read buffer.
@throw std::invalid_argument If the buffer size is less than 8.
*/
void
read_buffer_size(std::size_t n)
{
if(n < 8)
BOOST_THROW_EXCEPTION(std::invalid_argument{
"read buffer size is too small"});
rd_buf_size_ = n;
}
/// Returns the read buffer size setting.
std::size_t
read_buffer_size() const
{
return rd_buf_size_;
}
/** Returns the close reason received from the peer.
This is only valid after a read completes with error::closed.

View File

@@ -556,7 +556,7 @@ public:
ws.auto_fragment(true);
ws.set_option(write_buffer_size{2048});
ws.binary(false);
ws.set_option(read_buffer_size{8192});
ws.read_buffer_size(8192);
ws.set_option(read_message_max{1 * 1024 * 1024});
try
{