CppCommon  1.0.4.1
C++ Common Library
token_bucket.inl
Go to the documentation of this file.
1 
9 namespace CppCommon {
10 
11 inline TokenBucket::TokenBucket(uint64_t rate, uint64_t burst)
12  : _time(0),
13  _time_per_token(1000000000 / rate),
14  _time_per_burst(burst * _time_per_token)
15 {
16 
17 }
18 
20  : _time(tb._time.load()),
21  _time_per_token(tb._time_per_token.load()),
22  _time_per_burst(tb._time_per_burst.load())
23 {
24 }
25 
27 {
28  _time = tb._time.load();
29  _time_per_token = tb._time_per_token.load();
30  _time_per_burst = tb._time_per_burst.load();
31  return *this;
32 }
33 
34 } // namespace CppCommon
Token bucket rate limit algorithm.
Definition: token_bucket.h:34
TokenBucket(uint64_t rate, uint64_t burst)
Initialize the token bucket.
TokenBucket & operator=(const TokenBucket &tb)
C++ Common project definitions.
Definition: token_bucket.h:15