Meter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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_SRC_MEM_METER_H
10 #define SQUID_SRC_MEM_METER_H
11 
12 #include "SquidTime.h"
13 
14 namespace Mem
15 {
16 
20 class Meter
21 {
22 public:
24 
26  void flush() {level=0;}
27 
28  ssize_t currentLevel() const {return level;}
29  ssize_t peak() const {return hwater_level;}
30  time_t peakTime() const {return hwater_stamp;}
31 
32  Meter &operator ++() {++level; checkHighWater(); return *this;}
33  Meter &operator --() {--level; return *this;}
34 
35  Meter &operator +=(ssize_t n) { level += n; checkHighWater(); return *this;}
36  Meter &operator -=(ssize_t n) { level -= n; return *this;}
37 
38 private:
41  void checkHighWater() {
42  if (hwater_level < level) {
45  }
46  }
47 
48  ssize_t level;
49  ssize_t hwater_level;
50  time_t hwater_stamp;
51 };
52 
53 } // namespace Mem
54 
55 #endif /* SQUID_SRC_MEM_METER_H */
56 
void flush()
flush the meter level back to 0, but leave peak records
Definition: Meter.h:26
Meter()
Definition: Meter.h:23
Meter & operator-=(ssize_t n)
Definition: Meter.h:36
Meter & operator--()
Definition: Meter.h:33
ssize_t hwater_level
high water mark
Definition: Meter.h:49
time_t hwater_stamp
timestamp of last high water mark change
Definition: Meter.h:50
ssize_t peak() const
Definition: Meter.h:29
time_t squid_curtime
Definition: stub_time.cc:17
Meter & operator+=(ssize_t n)
Definition: Meter.h:35
Meter & operator++()
Definition: Meter.h:32
time_t peakTime() const
Definition: Meter.h:30
void checkHighWater()
Definition: Meter.h:41
ssize_t level
current level (count or volume)
Definition: Meter.h:48
ssize_t currentLevel() const
Definition: Meter.h:28
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors