CachePeers.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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_CACHEPEERS_H
10#define SQUID_CACHEPEERS_H
11
12#include "base/forward.h"
13#include "CachePeer.h"
15
16#include <memory>
17#include <vector>
18
21{
22public:
24 using Storage = std::vector< std::unique_ptr<CachePeer>, PoolingAllocator< std::unique_ptr<CachePeer> > >;
25
27 void add(CachePeer *p) { storage.emplace_back(p); }
28
30 void remove(CachePeer *);
31
33 auto size() const { return storage.size(); }
34
35 /* peer iterators forming a sequence for C++ range-based for loop API */
36 using const_iterator = Storage::const_iterator;
37 auto begin() const { return storage.cbegin(); }
38 auto end() const { return storage.cend(); }
39
43 CachePeer &nextPeerToPing(size_t iteration);
44
45private:
48
50 uint64_t peerPolls_ = 0;
51};
52
57
60
63using SelectedCachePeers = std::vector< CbcPointer<CachePeer>, PoolingAllocator< CbcPointer<CachePeer> > >;
64
66using RawCachePeers = std::vector<CachePeer *, PoolingAllocator<CachePeer*> >;
67
68#endif /* SQUID_CACHEPEERS_H */
69
const CachePeers & CurrentCachePeers()
Definition: CachePeers.cc:41
std::vector< CachePeer *, PoolingAllocator< CachePeer * > > RawCachePeers
Temporary, local storage of raw pointers to zero or more Config.peers.
Definition: CachePeers.h:66
std::vector< CbcPointer< CachePeer >, PoolingAllocator< CbcPointer< CachePeer > > > SelectedCachePeers
Definition: CachePeers.h:63
void DeleteConfigured(CachePeer *)
destroys the given peer after removing it from the set of configured peers
Definition: CachePeers.cc:51
cache_peer configuration storage
Definition: CachePeers.h:21
std::vector< std::unique_ptr< CachePeer >, PoolingAllocator< std::unique_ptr< CachePeer > > > Storage
owns stored CachePeer objects
Definition: CachePeers.h:24
auto begin() const
Definition: CachePeers.h:37
CachePeer & nextPeerToPing(size_t iteration)
Definition: CachePeers.cc:14
void add(CachePeer *p)
stores a being-configured cache_peer
Definition: CachePeers.h:27
Storage storage
cache_peers in configuration/parsing order
Definition: CachePeers.h:47
Storage::const_iterator const_iterator
Definition: CachePeers.h:36
void remove(CachePeer *)
deletes a previously add()ed CachePeer object
Definition: CachePeers.cc:31
auto end() const
Definition: CachePeers.h:38
auto size() const
the number of currently stored (i.e. added and not removed) cache_peers
Definition: CachePeers.h:33
uint64_t peerPolls_
total number of completed peer scans by nextPeerToPing()-calling code
Definition: CachePeers.h:50
STL Allocator that uses Squid memory pools for memory management.

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors