|
Squid Web Cache master
|
Counts events, forgetting old ones. Useful for "3 errors/minute" limits. More...
#include <FadingCounter.h>
Public Member Functions | |
| FadingCounter () | |
| void | configure (double horizonSeconds) |
| 0=remember nothing; -1=forget nothing; new value triggers clear() | |
| void | clear () |
| forgets all events | |
| int | count (int howMany) |
| count fresh, return #events remembered | |
| int | remembered () const |
| possibly stale #events | |
Public Attributes | |
| double | horizon |
| read-only memory horizon in seconds; older events are forgotten | |
Private Attributes | |
| const int | precision |
| #counting slots, controls measur. accuracy | |
| double | delta |
| sub-interval duration = horizon/precision | |
| double | lastTime |
| time of the last update | |
| std::vector< int > | counters |
| events per delta (possibly stale) | |
| int | total |
| number of remembered events (possibly stale) | |
Definition at line 15 of file FadingCounter.h.
| FadingCounter::FadingCounter | ( | ) |
Definition at line 17 of file FadingCounter.cc.
| void FadingCounter::clear | ( | ) |
Definition at line 25 of file FadingCounter.cc.
References counters, current_dtime, lastTime, precision, and total.
Referenced by configure(), and count().
| void FadingCounter::configure | ( | double | horizonSeconds | ) |
Definition at line 33 of file FadingCounter.cc.
References clear(), delta, horizon, and precision.
Referenced by Ssl::ClientBio::ClientBio().
|
inline |
Definition at line 26 of file FadingCounter.h.
References total.
|
private |
Definition at line 36 of file FadingCounter.h.
Referenced by FadingCounter(), clear(), and count().
|
private |
Definition at line 33 of file FadingCounter.h.
Referenced by configure(), and count().
| double FadingCounter::horizon |
Definition at line 29 of file FadingCounter.h.
Referenced by configure(), and count().
|
private |
Definition at line 35 of file FadingCounter.h.
|
private |
Definition at line 32 of file FadingCounter.h.
Referenced by FadingCounter(), clear(), configure(), and count().
|
private |
Definition at line 37 of file FadingCounter.h.
Referenced by clear(), count(), and remembered().