update actual amount of tokens in bucket

This commit is contained in:
serxa 2023-09-18 18:12:55 +00:00
parent 1787803157
commit c5f3170a82

View File

@ -125,7 +125,9 @@ public:
double getTokens() const
{
return tokens;
auto now = event_queue->now();
double elapsed = std::chrono::nanoseconds(now - last_update).count() / 1e9;
return std::min(tokens + max_speed * elapsed, max_burst);
}
std::chrono::nanoseconds getThrottlingDuration() const