]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/icap/History.cc
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / src / adaptation / icap / History.cc
1 #include "squid-old.h"
2 #include "adaptation/icap/History.h"
3 #include "globals.h"
4 #include "SquidTime.h"
5
6 Adaptation::Icap::History::History():
7 logType(LOG_TAG_NONE), req_sz(0),
8 pastTime(0), concurrencyLevel(0)
9 {
10 }
11
12 void Adaptation::Icap::History::start(const char *context)
13 {
14 if (!concurrencyLevel++)
15 currentStart = current_time;
16
17 debugs(93,4, HERE << "start " << context << " level=" << concurrencyLevel
18 << " time=" << pastTime << ' ' << this);
19 }
20
21 void Adaptation::Icap::History::stop(const char *context)
22 {
23 if (!concurrencyLevel) {
24 debugs(93,1, HERE << "Internal error: poor history accounting " << this);
25 return;
26 }
27
28 const int current = currentTime();
29 debugs(93,4, HERE << "stop " << context << " level=" << concurrencyLevel <<
30 " time=" << pastTime << '+' << current << ' ' << this);
31
32 if (!--concurrencyLevel)
33 pastTime += current;
34 }
35
36 int Adaptation::Icap::History::processingTime() const
37 {
38 const int total = pastTime + currentTime();
39 debugs(93,7, HERE << " current total: " << total << ' ' << this);
40 return total;
41 }
42
43 int Adaptation::Icap::History::currentTime() const
44 {
45 return concurrencyLevel > 0 ?
46 max(0, tvSubMsec(currentStart, current_time)) : 0;
47 }