...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
An instance of RatePolicy is associated
with a basic_stream
, and controls the rate
at which bytes may be independently sent and received. This may be used to
achieve fine-grained bandwidth management and flow control.
Warning | |
---|---|
These requirements may undergo non-backward compatible changes in subsequent versions. |
In this table:
P
denotes a type that
meets the requirements of RatePolicy.
x
denotes an xvalue of
type P
a
denotes a value of
type P
.
n
denotes a value of
type std::size_t
Table 1.44. Valid expressions
Expression |
Type |
Semantics, Pre/Post-conditions |
---|---|---|
|
Requires MoveConstructible. |
|
|
The member functions required in |
|
|
|
This function is called by the implementation to determine the maximum number of allowed bytes to be transferred in the next read operation. The actual number of bytes subsequently transferred may be less than this number. If the policy returns a value of zero, the read operation will asynchronously wait until the next timer interval before retrying. When the retry occurs, this function will be called again. |
|
|
This function is called by the implementation to determine the maximum number of allowed bytes to be transferred in the next write operation. The actual number of bytes subsequently transferred may be less than this number. If the policy returns a value of zero, the read operation will asynchronously wait until the next timer interval before retrying. When the retry occurs, this function will be called again. |
|
The implementation calls this function to inform the policy that
|
|
|
The implementation calls this function to inform the policy that
|
|
|
The implementation calls this function every time the internal timer expires. The policy object may optionally use this opportunity to calculate elapsed time and throughput, and/or inform the algorithm used to determine subsequently queried transfer limits. |
class RatePolicy { friend class rate_policy_access; std::size_t available_read_bytes(); std::size_t available_write_bytes(); void transfer_read_bytes(std::size_t); void transfer_write_bytes(std::size_t); void on_timer(); };