18 uint64_t delay = tokens * _time_per_token.load(std::memory_order_relaxed);
19 uint64_t minTime = now - _time_per_burst.load(std::memory_order_relaxed);
20 uint64_t oldTime = _time.load(std::memory_order_relaxed);
21 uint64_t newTime = oldTime;
24 if (minTime > oldTime)
38 if (_time.compare_exchange_weak(oldTime, newTime, std::memory_order_relaxed, std::memory_order_relaxed))
static uint64_t nano()
Get the high resolution timestamp.
bool Consume(uint64_t tokens=1)
Try to consume the given count of tokens.
C++ Common project definitions.
Token bucket rate limit algorithm definition.