FadingCounter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 #ifndef SQUID_FADING_COUNTER_H
10 #define SQUID_FADING_COUNTER_H
11 
12 #include <vector>
13 
16 {
17 public:
18  FadingCounter();
19 
21  void configure(double horizonSeconds);
22 
23  void clear();
24 
25  int count(int howMany);
26  int remembered() const { return total; }
27 
29  double horizon;
30 
31 private:
32  const int precision;
33  double delta;
34 
35  double lastTime;
36  std::vector<int> counters;
37  int total;
38 };
39 
40 #endif /* SQUID_FADING_COUNTER_H */
41 
double horizon
read-only memory horizon in seconds; older events are forgotten
Definition: FadingCounter.h:29
int count(int howMany)
count fresh, return #events remembered
Counts events, forgetting old ones. Usefull for "3 errors/minute" limits.
Definition: FadingCounter.h:15
void clear()
forgets all events
int remembered() const
possibly stale #events
Definition: FadingCounter.h:26
std::vector< int > counters
events per delta (possibly stale)
Definition: FadingCounter.h:36
void configure(double horizonSeconds)
0=remember nothing; -1=forget nothing; new value triggers clear()
double delta
sub-interval duration = horizon/precision
Definition: FadingCounter.h:33
int total
number of remembered events (possibly stale)
Definition: FadingCounter.h:37
const int precision
#counting slots, controls measur. occuracy
Definition: FadingCounter.h:32
double lastTime
time of the last update
Definition: FadingCounter.h:35

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors