16class TokenBucket
final {
18 using TimePoint = std::chrono::steady_clock::time_point;
19 using Duration = std::chrono::steady_clock::duration;
39 Duration single_token_update_interval);
44 TokenBucket(
const TokenBucket&) =
delete;
45 TokenBucket(TokenBucket&&)
noexcept;
46 TokenBucket& operator=(
const TokenBucket&) =
delete;
47 TokenBucket& operator=(TokenBucket&&)
noexcept;
49 bool IsUnbounded()
const;
94 std::atomic<size_t> max_size_;
95 std::atomic<size_t> token_refill_amount_;
96 std::atomic<Duration> token_refill_interval_;
97 std::atomic<size_t> tokens_;
98 std::atomic<TimePoint> last_update_;