Squid Web Cache master
Loading...
Searching...
No Matches
Incoming.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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_COMM_INCOMING_H
10#define SQUID_SRC_COMM_INCOMING_H
11
12#if USE_POLL || USE_SELECT
13
14#include "SquidConfig.h"
15#include "StatHist.h"
16
17namespace Comm
18{
19
40{
41public:
42#if !defined(INCOMING_FACTOR)
43#define INCOMING_FACTOR 5
44#endif
50 static const int Factor = INCOMING_FACTOR;
51
56 static const int MaxInterval = (256 << Factor);
57
58 // TODO replace with constructor initialization
59 void init(int n) { nMaximum = n; history.enumInit(n); }
60
68 bool startPolling(int n) { ioEvents = 0; return (n > 0); }
69
78
86 bool check() { return (++ioEvents > (interval >> Factor)); }
87
88 /*
89 * How many normal I/O events to process before checking
90 * incoming sockets again.
91 *
92 * \note We store the interval multiplied by a factor of
93 * (2^Factor) to have some pseudo-floating
94 * point precision.
95 */
96 int interval = (16 << Factor);
97
105
106private:
112 int ioEvents = 0;
113
118 int nMaximum = 0;
119};
120
121} // namespace Comm
122
123#endif /* USE_POLL || USE_SELECT */
124#endif /* SQUID_SRC_COMM_INCOMING_H */
#define INCOMING_FACTOR
Definition Incoming.h:43
void init(int n)
Definition Incoming.h:59
static const int MaxInterval
Definition Incoming.h:56
bool check()
Definition Incoming.h:86
bool startPolling(int n)
Definition Incoming.h:68
void finishPolling(int, SquidConfig::CommIncoming::Measure &)
Definition Incoming.cc:15
StatHist history
Definition Incoming.h:104
static const int Factor
Definition Incoming.h:50
void enumInit(unsigned int last_enum)
Definition StatHist.cc:235
Abstraction layer for TCP, UDP, TLS, UDS and filedescriptor sockets.