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

 

Introduction

Documentation

Support

Miscellaneous