9 #ifndef CPPCOMMON_ALGORITHMS_TOKEN_BUCKET_H
10 #define CPPCOMMON_ALGORITHMS_TOKEN_BUCKET_H
57 bool Consume(uint64_t tokens = 1);
60 std::atomic<uint64_t> _time;
61 std::atomic<uint64_t> _time_per_token;
62 std::atomic<uint64_t> _time_per_burst;
Token bucket rate limit algorithm.
TokenBucket(TokenBucket &&)=delete
bool Consume(uint64_t tokens=1)
Try to consume the given count of tokens.
TokenBucket & operator=(TokenBucket &&)=delete
TokenBucket(uint64_t rate, uint64_t burst)
Initialize the token bucket.
TokenBucket & operator=(const TokenBucket &tb)
C++ Common project definitions.
Token bucket rate limit algorithm inline implementation.