]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/FadingCounter.h
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_FADING_COUNTER_H
10 #define SQUID_FADING_COUNTER_H
14 /// Counts events, forgetting old ones. Usefull for "3 errors/minute" limits.
20 /// 0=remember nothing; -1=forget nothing; new value triggers clear()
21 void configure(double horizonSeconds
);
23 void clear(); ///< forgets all events
25 int count(int howMany
); ///< count fresh, return #events remembered
26 int remembered() const { return total
; } ///< possibly stale #events
28 /// read-only memory horizon in seconds; older events are forgotten
32 const int precision
; ///< #counting slots, controls measur. occuracy
33 double delta
; ///< sub-interval duration = horizon/precision
35 double lastTime
; ///< time of the last update
36 std::vector
<int> counters
; ///< events per delta (possibly stale)
37 int total
; ///< number of remembered events (possibly stale)
40 #endif /* SQUID_FADING_COUNTER_H */