Transients.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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_TRANSIENTS_H
10#define SQUID_TRANSIENTS_H
11
12#include "ipc/mem/Page.h"
13#include "ipc/mem/PageStack.h"
14#include "ipc/StoreMap.h"
15#include "Store.h"
16#include "store/Controlled.h"
17#include "store/forward.h"
18#include <vector>
19
21
28{
29public:
32 {
33 public:
34 bool hasWriter = false;
35 bool waitingToBeFreed = false;
36 };
37
38 Transients();
39 virtual ~Transients();
40
42 StoreEntry *findCollapsed(const sfileno xitIndex);
43
46 void monitorIo(StoreEntry*, const cache_key*, const Store::IoStatus);
47
49 void completeWriting(const StoreEntry &e);
50
52 void status(const StoreEntry &e, EntryStatus &entryStatus) const;
53
55 int readers(const StoreEntry &e) const;
56
58 void disconnect(StoreEntry &);
59
60 /* Store API */
61 virtual StoreEntry *get(const cache_key *) override;
62 virtual void create() override {}
63 virtual void init() override;
64 virtual uint64_t maxSize() const override;
65 virtual uint64_t minSize() const override;
66 virtual uint64_t currentSize() const override;
67 virtual uint64_t currentCount() const override;
68 virtual int64_t maxObjectSize() const override;
69 virtual void getStats(StoreInfoStats &stats) const override;
70 virtual void stat(StoreEntry &e) const override;
71 virtual void reference(StoreEntry &e) override;
72 virtual bool dereference(StoreEntry &e) override;
73 virtual void evictCached(StoreEntry &) override;
74 virtual void evictIfFound(const cache_key *) override;
75 virtual void maintain() override;
76
79 bool markedForDeletion(const cache_key *) const;
80
82 bool isReader(const StoreEntry &) const;
84 bool isWriter(const StoreEntry &) const;
86 bool hasWriter(const StoreEntry &);
87
88 static int64_t EntryLimit();
89
91 static bool Enabled() { return EntryLimit(); }
92
93protected:
94 void addEntry(StoreEntry*, const cache_key *, const Store::IoStatus);
95 void addWriterEntry(StoreEntry &, const cache_key *);
96 void addReaderEntry(StoreEntry &, const cache_key *);
97 void anchorEntry(StoreEntry &, const sfileno, const Ipc::StoreMapAnchor &);
98
99 // Ipc::StoreMapCleaner API
100 virtual void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override;
101
102private:
105
106 typedef std::vector<StoreEntry*> Locals;
110};
111
112// TODO: Why use Store as a base? We are not really a cache.
113
114#endif /* SQUID_TRANSIENTS_H */
115
Ipc::StoreMap TransientsMap
Definition: Transients.h:20
API for adjusting external state when dirty map slice is being freed.
Definition: StoreMap.h:398
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:14
shared entry metadata, used for synchronization
Definition: Transients.h:32
bool waitingToBeFreed
whether the entry was marked for deletion
Definition: Transients.h:35
bool hasWriter
whether some worker is storing the entry
Definition: Transients.h:34
int readers(const StoreEntry &e) const
number of entry readers some time ago
Definition: Transients.cc:312
virtual StoreEntry * get(const cache_key *) override
Definition: Transients.cc:146
bool hasWriter(const StoreEntry &)
whether we or somebody else is in the "writing to Transients" I/O state
Definition: Transients.cc:275
void monitorIo(StoreEntry *, const cache_key *, const Store::IoStatus)
Definition: Transients.cc:192
void addReaderEntry(StoreEntry &, const cache_key *)
Definition: Transients.cc:250
Locals * locals
Definition: Transients.h:109
virtual void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override
adjust slice-linked state before a locked Readable slice is erased
Definition: Transients.cc:283
virtual ~Transients()
Definition: Transients.cc:34
TransientsMap * map
shared packed info indexed by Store keys, for creating new StoreEntries
Definition: Transients.h:104
void addWriterEntry(StoreEntry &, const cache_key *)
addEntry() helper used for cache entry creators/writers
Definition: Transients.cc:228
bool isWriter(const StoreEntry &) const
whether the entry is in "writing to Transients" I/O state
Definition: Transients.cc:392
void disconnect(StoreEntry &)
the caller is done writing or reading the given entry
Definition: Transients.cc:347
StoreEntry * findCollapsed(const sfileno xitIndex)
return a local, previously collapsed entry
Definition: Transients.cc:176
void anchorEntry(StoreEntry &, const sfileno, const Ipc::StoreMapAnchor &)
fills (recently created) StoreEntry with information currently in Transients
Definition: Transients.cc:263
virtual void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: Transients.cc:56
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Transients.cc:126
virtual void stat(StoreEntry &e) const override
Definition: Transients.cc:73
virtual void create() override
create system resources needed for this store to operate in the future
Definition: Transients.h:62
void addEntry(StoreEntry *, const cache_key *, const Store::IoStatus)
creates a new Transients entry
Definition: Transients.cc:211
bool markedForDeletion(const cache_key *) const
Definition: Transients.cc:379
virtual void evictCached(StoreEntry &) override
Definition: Transients.cc:322
void status(const StoreEntry &e, EntryStatus &entryStatus) const
copies current shared entry metadata into entryStatus
Definition: Transients.cc:289
virtual uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: Transients.cc:99
virtual void reference(StoreEntry &e) override
somebody needs this entry (many cache replacement policies need to know)
Definition: Transients.cc:133
virtual void init() override
Definition: Transients.cc:41
virtual uint64_t maxSize() const override
Definition: Transients.cc:105
virtual bool dereference(StoreEntry &e) override
Definition: Transients.cc:139
virtual void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: Transients.cc:93
static int64_t EntryLimit()
calculates maximum number of entries we need to store and map
Definition: Transients.cc:372
bool isReader(const StoreEntry &) const
whether the entry is in "reading from Transients" I/O state
Definition: Transients.cc:386
virtual uint64_t currentSize() const override
current size
Definition: Transients.cc:112
void completeWriting(const StoreEntry &e)
called when the in-transit entry has been successfully cached
Definition: Transients.cc:301
virtual uint64_t currentCount() const override
the total number of objects stored right now
Definition: Transients.cc:120
std::vector< StoreEntry * > Locals
Definition: Transients.h:106
virtual void evictIfFound(const cache_key *) override
Definition: Transients.cc:336
static bool Enabled()
Can we create and initialize Transients?
Definition: Transients.h:91
int32_t StoreMapSliceId
Definition: StoreMap.h:24
class Ping::pingStats_ stats
IoStatus
cache "I/O" direction and status
Definition: forward.h:40
unsigned char cache_key
Store key.
Definition: forward.h:29
signed_int32_t sfileno
Definition: forward.h:22

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors