Class RateLimiter¶
Defined in File RateLimiter.hpp
Class Documentation¶
-
class
rmf_utils
::
RateLimiter
¶ A class used to track limits in the rate at which an event may occur. A counter will increment each time reached_limit() is called within a time period.
If the counter reaches its limit then reached_limit() will return true.
If the counter has not reached its limit then reached_limit() will return false.
If reached_limit() is called again after the period limit has passed, then the time period will be reset and the function will return false.
Public Functions
-
RateLimiter
(std::chrono::steady_clock::duration period_limit_, std::size_t count_limit_)¶ Constructor
- Parameters
[in] period_limit_
: How long between events before the counter is reset to zero[in] count_limit_
: How high the counter can reach before check() returns false
-
bool
reached_limit
() const¶
-
std::chrono::steady_clock::duration
period_limit
() const¶
-
RateLimiter &
period_limit
(std::chrono::steady_clock::duration new_limit)¶
-
std::size_t
count_limit
() const¶
-
RateLimiter &
count_limit
(std::size_t new_limit)¶
-