StoreMap.h
Go to the documentation of this file.
130 static size_t SharedMemorySize(const int aCapacity) { return sizeof(StoreMapItems<Item>) + aCapacity*sizeof(Item); }
Definition: FlexibleArray.h:27
Definition: Pointer.h:26
Definition: Pointer.h:83
Definition: ReadWriteLock.h:27
std::atomic< bool > writing
there is a writing user (there can be at most 1)
Definition: ReadWriteLock.h:55
Definition: StoreMap.h:57
std::atomic< StoreMapSliceId > splicingPoint
Definition: StoreMap.h:115
std::atomic< StoreMapSliceId > start
where the chain of StoreEntry slices begins [app]
Definition: StoreMap.h:111
void rewind()
undo the effects of set(), setKey(), etc., but keep locks and state
Definition: StoreMap.cc:1002
bool sameKey(const cache_key *const aKey) const
Definition: StoreMap.cc:951
struct Ipc::StoreMapAnchor::Basics basics
std::atomic< uint8_t > writerHalted
whether StoreMap::abortWriting() was called for a read-locked entry
Definition: StoreMap.h:83
void set(const StoreEntry &anEntry, const cache_key *aKey=nullptr)
store StoreEntry key and basics for an inode slot
Definition: StoreMap.cc:958
std::atomic< uint8_t > waitingToBeFreed
Definition: StoreMap.h:81
void exportInto(StoreEntry &) const
load StoreEntry basics that were previously stored with set()
Definition: StoreMap.cc:978
Definition: StoreMap.h:161
StoreMapAnchors(const int aCapacity)
Definition: StoreMap.cc:1053
static size_t SharedMemorySize(const int anAnchorLimit)
Definition: StoreMap.cc:1068
API for adjusting external state when dirty map slice is being freed.
Definition: StoreMap.h:398
virtual void noteFreeMapSlice(const StoreMapSliceId sliceId)=0
adjust slice-linked state before a locked Readable slice is erased
Definition: StoreMap.h:122
static size_t SharedMemorySize(const int aCapacity)
Definition: StoreMap.h:130
Definition: StoreMap.h:29
StoreMapSlice & operator=(const StoreMapSlice &o)
Definition: StoreMap.h:39
During an update, the stored entry has two editions: stale and fresh.
Definition: StoreMap.h:186
sfileno name
StoreEntry position in StoreMap::fileNos, for swapping Editions.
Definition: StoreMap.h:195
StoreMapSliceId splicingPoint
the last slice in the chain still containing metadata/headers
Definition: StoreMap.h:198
Aggregates information required for updating entry metadata and headers.
Definition: StoreMap.h:182
StoreMapUpdate & operator=(const StoreMapUpdate &other)=delete
aggregates anchor and slice owners for Init() caller convenience
Definition: StoreMap.h:233
Owner & operator=(const Owner &)
Owner(const Owner &)
Definition: StoreMap.h:219
Anchor * openForWriting(const cache_key *const key, sfileno &fileno)
Definition: StoreMap.cc:140
const Slice & readableSlice(const AnchorId anchorId, const SliceId sliceId) const
readable slice within an entry chain opened by openForReading()
Definition: StoreMap.cc:229
const Anchor * openForReadingAt(const sfileno, const cache_key *const)
opens entry (identified by sfileno) for reading, increments read level
Definition: StoreMap.cc:452
bool openForUpdating(Update &update, sfileno fileNoHint)
finds and locks the Update entry for an exclusive metadata update
Definition: StoreMap.cc:522
Anchor * openForWritingAt(sfileno fileno, bool overwriteExisting=true)
Definition: StoreMap.cc:155
bool markedForDeletion(const cache_key *const)
Definition: StoreMap.cc:354
Anchor & writeableEntry(const AnchorId anchorId)
writeable anchor for the entry created by openForWriting()
Definition: StoreMap.cc:237
const Anchor * peekAtReader(const sfileno fileno) const
Definition: StoreMap.cc:286
const Anchor & readableEntry(const AnchorId anchorId) const
readable anchor for the entry created by openForReading()
Definition: StoreMap.cc:244
void closeForUpdateFinal(Update &update)
Anchor & anchorByKey(const cache_key *const key)
Definition: StoreMap.cc:918
static Owner * Init(const SBuf &path, const int slotLimit)
initialize shared memory
Definition: StoreMap.cc:42
void relocate(const sfileno name, const sfileno fileno)
map name to fileNo
Definition: StoreMap.cc:904
void freeChain(const sfileno fileno, Anchor &inode, const bool keepLock)
unconditionally frees an already locked chain of slots, unlocking if needed
Definition: StoreMap.cc:374
void closeForWriting(const sfileno fileno)
successfully finish creating or updating the entry at fileno pos
Definition: StoreMap.cc:200
const Anchor * openOrCreateForReading(const cache_key *, sfileno &)
openForReading() but creates a new entry if there is no old one
Definition: StoreMap.cc:103
void abortUpdating(Update &update)
undoes partial update, unlocks, and cleans up
Definition: StoreMap.cc:268
SliceId sliceContaining(const sfileno fileno, const uint64_t nth) const
Definition: StoreMap.cc:420
const Anchor * openForReading(const cache_key *const key, sfileno &fileno)
opens entry (identified by key) for reading, increments read level
Definition: StoreMap.cc:439
void forgetWritingEntry(const sfileno fileno)
Definition: StoreMap.cc:84
int compareVersions(const sfileno oldFileno, time_t newVersion) const
Definition: StoreMap.cc:68
void closeForReading(const sfileno fileno)
closes open entry after reading, decrements read level
Definition: StoreMap.cc:496
void importSlice(const SliceId sliceId, const Slice &slice)
copies slice to its designated position
Definition: StoreMap.cc:721
const Anchor * peekAtWriter(const sfileno fileno) const
Definition: StoreMap.cc:296
void closeForReadingAndFreeIdle(const sfileno fileno)
same as closeForReading() but also frees the entry if it is unlocked
Definition: StoreMap.cc:505
void abortWriting(const sfileno fileno)
stop writing the entry, freeing its slot for others to use if possible
Definition: StoreMap.cc:251
void startAppending(const sfileno fileno)
restrict opened for writing entry to appending operations; allow reads
Definition: StoreMap.cc:191
sfileno nameByKey(const cache_key *const key) const
computes entry name (i.e., key hash) for a given entry key
Definition: StoreMap.cc:883
Anchor * openForReading(Slice &s)
void prepFreeSlice(const SliceId sliceId)
prepare a chain-unaffiliated slice for being added to an entry chain
Definition: StoreMap.cc:412
void closeForUpdating(Update &update)
makes updated info available to others, unlocks, and cleans up
Definition: StoreMap.cc:604
std::function< bool(const sfileno name)> NameFilter
Definition: StoreMap.h:386
bool purgeOne()
either finds and frees an entry with at least 1 slice or returns false
Definition: StoreMap.cc:701
void updateStats(ReadWriteLockStats &stats) const
adds approximate current stats to the supplied ones
Definition: StoreMap.cc:750
sfileno fileNoByKey(const cache_key *const key) const
computes map entry anchor position for a given entry key
Definition: StoreMap.cc:911
bool hasReadableEntry(const cache_key *const)
whether the index contains a valid readable entry with the given key
Definition: StoreMap.cc:362
void freeEntryByKey(const cache_key *const key)
Definition: StoreMap.cc:330
sfileno fileNoByName(const sfileno name) const
computes anchor position for a given entry name
Definition: StoreMap.cc:893
const Anchor & peekAtEntry(const sfileno fileno) const
Definition: StoreMap.cc:306
Slice & writeableSlice(const AnchorId anchorId, const SliceId sliceId)
writeable slice within an entry chain created by openForWriting()
Definition: StoreMap.cc:221
void switchWritingToReading(const sfileno fileno)
stop writing (or updating) the locked entry and start reading it
Definition: StoreMap.cc:211
void freeChainAt(SliceId sliceId, const SliceId splicingPoint)
unconditionally frees an already locked chain of slots; no anchor maintenance
Definition: StoreMap.cc:390
Definition: Store.h:42
Definition: IpcIoFile.h:24
StoreMapItems< std::atomic< sfileno > > StoreMapFileNos
StoreMapAnchor positions, indexed by entry "name" (i.e., the entry key hash)
Definition: StoreMap.h:178
StoreMapItems< StoreMapSlice > StoreMapSlices
StoreMapSlices indexed by their slice ID.
Definition: StoreMap.h:156
class Ping::pingStats_ stats
Definition: StoreMap.h:91
std::atomic< uint64_t > swap_file_sz
Definition: StoreMap.h:105