struct throttle_counter
Defined at line 39 of file ../../src/connectivity/wlan/drivers/lib/log/cpp/include/common/wlan/drivers/internal/throttle_counter.h
Struct that fixes the rate at which some event occurs to an upper bound.
Typical usage of this class looks as follows:
static struct throttle_counter tc = {
.capacity = CAPACITY, .tokens_per_second = RATE, .num_throttled_events = 0, .last_issued_tick
= 0
};
uint64_t num_throttled = 0;
if (throttle_counter_consume(
&tc
, num_throttled)) {
DO_SOMETHING();
}
Conceptually, throttle_counter works by generating tokens at a fixed rate. Users can then
"consume" a token to call some rate-limited function. Both the generation and consumption of
tokens is handled by the call to throttle_counter_consume().
This class is thread-safe if used with throttle_counter_consume().
Public Members
zx_ticks_t capacity
double tokens_per_second
atomic num_throttled_events
atomic last_issued_tick