1 #include "mfextensions/Extensions/throttle.hh"
4 : name_(name), expr_(regex_t(name)), what_(), limit_(limit), timespan_(timespan), last_window_start_(0), count_(0), in_use_(true) {}
8 if (!in_use_)
return false;
10 if (!boost::regex_match(name, what_, expr_))
return false;
21 return count_ > limit_ ?
true :
false;
25 if (sec - last_window_start_ > timespan_)
27 last_window_start_ = sec;
35 return count_ > limit_ ?
true :
false;
throttle(std::string const &name, int limit, long timespan)
Throttle messages using a regular expression if they occurr above a certain frequency ...
bool reach_limit(std::string const &name, timeval tm)
Determine whether the name has reached the throttling limit