9#ifndef SQUID_SRC_IPC_MEM_PAGESTACK_H
10#define SQUID_SRC_IPC_MEM_PAGESTACK_H
basic IdSet storage parameters, extracted here to keep them constant
uint32_t size_type
we need to fit two size_type counters into one 64-bit lockless atomic
size_type innerLevelCount
all levels except the leaf level
size_type capacity
the maximum number of pages our tree is allowed to store
size_type nodeCount() const
the total number of nodes at all levels
size_type leafNodeCount
the number of nodes at the leaf level
size_type treeHeight
total number of levels, including the leaf level
size_type requestedLeafNodeCount
the number of leaf nodes that satisfy capacity requirements
a shareable set of positive uint32_t IDs with O(1) insertion/removal ops
size_type leafPop(Position)
extracts and returns an ID from the leaf node at the given position
const IdSetMeasurements measurements
void leafTruncate(Position pos, size_type idsToKeep)
fill the leaf node at a given position with 0s, leaving only idsToKeep IDs
StoredNode & nodeAt(Position)
FlexibleArray< StoredNode > nodes_
the entire binary tree flattened into an array
void truncateExtras()
effectively removes IDs that exceed the requested capacity after makeFull()
size_type innerTruncate(Position pos, NavigationDirection dir, size_type toSubtract)
void makeFullBeforeSharing()
void innerPush(Position, NavigationDirection)
accounts for an ID added to subtree in the given dir from the given position
uint64_t Node
either leaf or intermediate node
static size_t MemorySize(size_type capacity)
memory size required to store a tree with the given capacity
Position ascend(Position)
Node * valueAddress(Position)
void push(size_type id)
makes id value available to future pop() callers
NavigationDirection innerPop(Position)
std::atomic< Node > StoredNode
a Node stored in shared memory
Position descend(Position, NavigationDirection)
void leafPush(Position, size_type id)
adds the given ID to the leaf node at the given position
IdSetMeasurements::size_type size_type
Shared memory page identifier, address, or handler.
PageStack construction and SharedMemorySize calculation parameters.
PageCount capacity
the maximum number of pages
size_t pageSize
page size, used to calculate shared memory size
bool createFull
whether a newly created PageStack should be prefilled with PageIds
static PoolId IdForMultipurposePool()
multipurpose PagePool of shared memory pages
IdSet ids_
free pages (valid with positive capacity_)
static size_t LevelsPaddingSize(const PageCount capacity)
static size_t SharedMemorySize(const Config &)
total shared memory size required to share
PageCount size() const
an approximate number of free pages
bool pageIdIsValid(const PageId &page) const
std::atomic< size_t > Levels_t
size_t levelsPaddingSize() const
PageCount capacity() const
std::atomic< PageCount > size_
a lower bound for the number of free pages (for debugging purposes)
static PoolId IdForMemStoreSpace()
stack of free cache_mem slot positions
static PoolId IdForSwapDirSpace(const int dirIdx)
stack of free rock cache_dir slot numbers
unsigned int PageCount
the number of (free and/or used) pages in a stack
size_t sharedMemorySize() const
static size_t StackSize(const PageCount capacity)
bool pop(PageId &page)
sets value and returns true unless no free page numbers are found
void push(PageId &page)
makes value available as a free page number to future pop() callers