/
usr
/
include
/
boost
/
beast
/
core
/
/usr/include/boost/beast/core
mkdir
upload
Name
Size
Mode
Actions
detail/
-
0755
rm
impl/
-
0755
rm
async_base.hpp
26461
0644
edit
dl
rm
basic_stream.hpp
55342
0644
edit
dl
rm
bind_handler.hpp
4172
0644
edit
dl
rm
buffered_read_stream.hpp
11877
0644
edit
dl
rm
buffers_adaptor.hpp
6783
0644
edit
dl
rm
buffers_cat.hpp
3383
0644
edit
dl
rm
buffers_prefix.hpp
6152
0644
edit
dl
rm
buffers_range.hpp
4211
0644
edit
dl
rm
buffers_suffix.hpp
3971
0644
edit
dl
rm
buffers_to_string.hpp
1770
0644
edit
dl
rm
buffer_traits.hpp
5757
0644
edit
dl
rm
detect_ssl.hpp
22345
0644
edit
dl
rm
error.hpp
2257
0644
edit
dl
rm
file.hpp
1028
0644
edit
dl
rm
file_base.hpp
5015
0644
edit
dl
rm
file_posix.hpp
4222
0644
edit
dl
rm
file_stdio.hpp
3849
0644
edit
dl
rm
file_win32.hpp
4248
0644
edit
dl
rm
flat_buffer.hpp
15427
0644
edit
dl
rm
flat_static_buffer.hpp
8706
0644
edit
dl
rm
flat_stream.hpp
12603
0644
edit
dl
rm
make_printable.hpp
2803
0644
edit
dl
rm
multi_buffer.hpp
18153
0644
edit
dl
rm
ostream.hpp
2690
0644
edit
dl
rm
rate_policy.hpp
4592
0644
edit
dl
rm
read_size.hpp
1844
0644
edit
dl
rm
role.hpp
1322
0644
edit
dl
rm
saved_handler.hpp
3788
0644
edit
dl
rm
span.hpp
4787
0644
edit
dl
rm
static_buffer.hpp
8515
0644
edit
dl
rm
static_string.hpp
25720
0644
edit
dl
rm
stream_traits.hpp
16399
0644
edit
dl
rm
string.hpp
1941
0644
edit
dl
rm
string_param.hpp
3459
0644
edit
dl
rm
string_type.hpp
1092
0644
edit
dl
rm
tcp_stream.hpp
853
0644
edit
dl
rm
Edit:
/usr/include/boost/beast/core/rate_policy.hpp
(4592B)
// // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Official repository: https://github.com/boostorg/beast // #ifndef BOOST_BEAST_CORE_RATE_POLICY_HPP #define BOOST_BEAST_CORE_RATE_POLICY_HPP #include <boost/beast/core/detail/config.hpp> #include <cstdint> #include <limits> namespace boost { namespace beast { /** Helper class to assist implementing a <em>RatePolicy</em>. This class is used by the implementation to gain access to the private members of a user-defined object meeting the requirements of <em>RatePolicy</em>. To use it, simply declare it as a friend in your class: @par Example @code class custom_rate_policy { friend class beast::rate_policy_access; ... @endcode @par Concepts @li <em>RatePolicy</em> @see beast::basic_stream */ class rate_policy_access { private: template<class, class, class> friend class basic_stream; template<class Policy> static std::size_t available_read_bytes(Policy& policy) { return policy.available_read_bytes(); } template<class Policy> static std::size_t available_write_bytes(Policy& policy) { return policy.available_write_bytes(); } template<class Policy> static void transfer_read_bytes( Policy& policy, std::size_t n) { return policy.transfer_read_bytes(n); } template<class Policy> static void transfer_write_bytes( Policy& policy, std::size_t n) { return policy.transfer_write_bytes(n); } template<class Policy> static void on_timer(Policy& policy) { return policy.on_timer(); } }; //------------------------------------------------------------------------------ /** A rate policy with unlimited throughput. This rate policy object does not apply any rate limit. @par Concepts @li <em>RatePolicy</em> @see beast::basic_stream, beast::tcp_stream */ class unlimited_rate_policy { friend class rate_policy_access; static std::size_t constexpr all = (std::numeric_limits<std::size_t>::max)(); std::size_t available_read_bytes() const noexcept { return all; } std::size_t available_write_bytes() const noexcept { return all; } void transfer_read_bytes(std::size_t) const noexcept { } void transfer_write_bytes(std::size_t) const noexcept { } void on_timer() const noexcept { } }; //------------------------------------------------------------------------------ /** A rate policy with simple, configurable limits on reads and writes. This rate policy allows for simple individual limits on the amount of bytes per second allowed for reads and writes. @par Concepts @li <em>RatePolicy</em> @see beast::basic_stream */ class simple_rate_policy { friend class rate_policy_access; static std::size_t constexpr all = (std::numeric_limits<std::size_t>::max)(); std::size_t rd_remain_ = all; std::size_t wr_remain_ = all; std::size_t rd_limit_ = all; std::size_t wr_limit_ = all; std::size_t available_read_bytes() const noexcept { return rd_remain_; } std::size_t available_write_bytes() const noexcept { return wr_remain_; } void transfer_read_bytes(std::size_t n) noexcept { if( rd_remain_ != all) rd_remain_ = (n < rd_remain_) ? rd_remain_ - n : 0; } void transfer_write_bytes(std::size_t n) noexcept { if( wr_remain_ != all) wr_remain_ = (n < wr_remain_) ? wr_remain_ - n : 0; } void on_timer() noexcept { rd_remain_ = rd_limit_; wr_remain_ = wr_limit_; } public: /// Set the limit of bytes per second to read void read_limit(std::size_t bytes_per_second) noexcept { rd_limit_ = bytes_per_second; if( rd_remain_ > bytes_per_second) rd_remain_ = bytes_per_second; } /// Set the limit of bytes per second to write void write_limit(std::size_t bytes_per_second) noexcept { wr_limit_ = bytes_per_second; if( wr_remain_ > bytes_per_second) wr_remain_ = bytes_per_second; } }; } // beast } // boost #endif
Save
cmd:
run