20 U32 replenishInterval,
26 m_replenishInterval(replenishInterval),
27 m_maxTokens(maxTokens),
28 m_replenishRate(replenishRate),
29 m_tokens(startTokens),
36 U32 replenishInterval,
39 m_replenishInterval(replenishInterval),
40 m_maxTokens(maxTokens),
45 FW_ASSERT(this->m_maxTokens <= MAX_TOKEN_BUCKET_TOKENS, this->m_maxTokens);
53 this->m_replenishInterval = replenishInterval;
61 this->m_maxTokens = maxTokens;
69 this->m_replenishRate = replenishRate;
75 if (this->m_tokens < this->m_maxTokens) {
76 this->m_tokens = this->m_maxTokens;
81 getReplenishInterval()
const
83 return this->m_replenishInterval;
89 return this->m_maxTokens;
93 getReplenishRate()
const
95 return this->m_replenishRate;
101 return this->m_tokens;
110 if (this->m_replenishRate > 0) {
111 Fw::Time replenishInterval =
Fw::Time(this->m_replenishInterval / 1000000, this->m_replenishInterval % 1000000);
113 while (this->m_tokens < this->m_maxTokens && nextTime <= time) {
115 this->m_tokens +=
FW_MIN(this->m_replenishRate, this->m_maxTokens - this->m_tokens);
116 this->m_time = nextTime;
119 if (this->m_tokens >= this->m_maxTokens && this->m_time < time) {
125 if (this->m_tokens > 0) {
#define FW_MIN(a, b)
MIN macro.
static Time add(const Time &a, const Time &b)