RatePolicy.qbk 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. [/
  2. Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. Official repository: https://github.com/boostorg/beast
  6. ]
  7. [section:RatePolicy RatePolicy]
  8. An instance of [*RatePolicy] is associated with a
  9. [link beast.ref.boost__beast__basic_stream `basic_stream`],
  10. and controls the rate at which bytes may be independently sent and
  11. received. This may be used to achieve fine-grained bandwidth management
  12. and flow control.
  13. [heading Associated Types]
  14. * [link beast.ref.boost__beast__rate_policy_access `rate_policy_access`]
  15. [warning
  16. These requirements may undergo non-backward compatible
  17. changes in subsequent versions.
  18. ]
  19. [heading Requirements]
  20. In this table:
  21. * `P` denotes a type that meets the requirements of [*RatePolicy].
  22. * `x` denotes an xvalue of type `P`
  23. * `a` denotes a value of type `P`.
  24. * `n` denotes a value of type `std::size_t`
  25. [table Valid expressions
  26. [[Expression] [Type] [Semantics, Pre/Post-conditions]]
  27. [
  28. [`P a(x)`]
  29. []
  30. [
  31. Requires ['MoveConstructible].
  32. ]
  33. ][
  34. [`friend rate_policy_access`]
  35. []
  36. [
  37. The member functions required in `P` should be private.
  38. [link beast.ref.boost__beast__rate_policy_access `rate_policy_access`]
  39. must be a friend of `P` for the implementation to gain access
  40. to the required member functions.
  41. ]
  42. ][
  43. [`a.available_read_bytes()`]
  44. [`std::size_t`]
  45. [
  46. This function is called by the implementation to determine
  47. the maximum number of allowed bytes to be transferred
  48. in the next read operation. The actual number of bytes
  49. subsequently transferred may be less than this number.
  50. If the policy returns a value of zero, the read operation
  51. will asynchronously wait until the next timer interval
  52. before retrying. When the retry occurs, this function will
  53. be called again.
  54. ]
  55. ][
  56. [`a.available_write_bytes()`]
  57. [`std::size_t`]
  58. [
  59. This function is called by the implementation to determine
  60. the maximum number of allowed bytes to be transferred
  61. in the next write operation. The actual number of bytes
  62. subsequently transferred may be less than this number.
  63. If the policy returns a value of zero, the read operation
  64. will asynchronously wait until the next timer interval
  65. before retrying. When the retry occurs, this function will
  66. be called again.
  67. ]
  68. ][
  69. [`a.transfer_read_bytes(n)`]
  70. []
  71. [
  72. The implementation calls this function to inform the
  73. policy that `n` bytes were successfully transferred
  74. in the most recent read operation. The policy object
  75. may optionally use this information to calculate
  76. throughputs and/or inform the algorithm used to
  77. determine subsequently queried transfer maximums.
  78. ]
  79. ][
  80. [`a.transfer_write_bytes(n)`]
  81. []
  82. [
  83. The implementation calls this function to inform the
  84. policy that `n` bytes were successfully transferred
  85. in the most recent write operation. The policy object
  86. may optionally use this information to calculate
  87. throughputs and/or inform the algorithm used to
  88. determine subsequently queried transfer limits.
  89. ]
  90. ][
  91. [`a.on_timer()`]
  92. []
  93. [
  94. The implementation calls this function every time the
  95. internal timer expires. The policy object may optionally
  96. use this opportunity to calculate elapsed time and
  97. throughput, and/or inform the algorithm used to
  98. determine subsequently queried transfer limits.
  99. ]
  100. ]]
  101. [heading Exemplar]
  102. [concept_RatePolicy]
  103. [heading Models]
  104. * [link beast.ref.boost__beast__simple_rate_policy `simple_rate_policy`]
  105. * [link beast.ref.boost__beast__unlimited_rate_policy `unlimited_rate_policy`]
  106. [endsect]