NDEVR
API Documentation
RateLimiter

Throttles the frequency of an action by enforcing a minimum time interval between firings. More...

Collaboration diagram for RateLimiter:
[legend]

Public Member Functions

 RateLimiter (fltp08 seconds)
 Constructs a RateLimiter with the specified minimum interval between firings.
void setCurrent (Time time)
 Sets the current reference time, resetting the rate limiter period.
bool shouldFire (Time time, bool update_for_next_period=true)
 Checks whether enough time has elapsed to allow the action to fire.

Protected Attributes

TimeSpan m_update_period
 The time span defining the minimum interval between firings.

Detailed Description

Throttles the frequency of an action by enforcing a minimum time interval between firings.


Definition at line 9 of file RateLimiter.h.

Constructor & Destructor Documentation

◆ RateLimiter()

RateLimiter::RateLimiter ( fltp08 seconds)
inline

Constructs a RateLimiter with the specified minimum interval between firings.

Parameters
[in]secondsThe minimum number of seconds that must elapse between firings.

Definition at line 16 of file RateLimiter.h.

References m_update_period.

Member Function Documentation

◆ setCurrent()

void RateLimiter::setCurrent ( Time time)
inline

Sets the current reference time, resetting the rate limiter period.

Parameters
[in]timeThe new reference time to start the period from.

Definition at line 23 of file RateLimiter.h.

References m_update_period.

◆ shouldFire()

bool RateLimiter::shouldFire ( Time time,
bool update_for_next_period = true )
inline

Checks whether enough time has elapsed to allow the action to fire.

Parameters
[in]timeThe current time to check against the rate limit period.
[in]update_for_next_periodWhether to reset the period start time when firing occurs.
Returns
True if the rate limit period has expired and the action should fire, false otherwise.

Definition at line 33 of file RateLimiter.h.

References m_update_period.


The documentation for this class was generated from the following file: