#include <PageStack.h>

Collaboration diagram for Ipc::Mem::PageStack:

Public Types

typedef uint32_t Value
 stack item type (a free page number) More...
 

Public Member Functions

 PageStack (const uint32_t aPoolId, const unsigned int aCapacity, const size_t aPageSize)
 
unsigned int capacity () const
 
size_t pageSize () const
 
unsigned int size () const
 lower bound for the number of free pages More...
 
bool pop (PageId &page)
 sets value and returns true unless no free page numbers are found More...
 
void push (PageId &page)
 makes value available as a free page number to future pop() callers More...
 
bool pageIdIsValid (const PageId &page) const
 
size_t sharedMemorySize () const
 
size_t stackSize () const
 

Static Public Member Functions

static size_t SharedMemorySize (const uint32_t aPoolId, const unsigned int capacity, const size_t pageSize)
 total shared memory size required to share More...
 
static size_t StackSize (const unsigned int capacity)
 

Private Types

typedef int Offset
 stack index and size type (may temporary go negative) More...
 
typedef std::atomic< ValueItem
 

Private Member Functions

Offset next (const Offset idx) const
 
Offset prev (const Offset idx) const
 

Private Attributes

const uint32_t thePoolId
 pool ID More...
 
const Offset theCapacity
 stack capacity, i.e. theItems size More...
 
const size_t thePageSize
 
std::atomic< OffsettheSize
 lower bound for the number of free pages (may get negative!) More...
 
std::atomic< OffsettheLastReadable
 last readable item index; just a hint, not a guarantee More...
 
std::atomic< OffsettheFirstWritable
 first writable item index; just a hint, not a guarantee More...
 
Ipc::Mem::FlexibleArray< ItemtheItems
 page number storage More...
 

Detailed Description

Atomic container of "free" page numbers inside a single SharedMemory space. Assumptions: all page numbers are unique, positive, have an known maximum, and can be temporary unavailable as long as they are never trully lost.

Definition at line 27 of file PageStack.h.

Member Typedef Documentation

typedef std::atomic<Value> Ipc::Mem::PageStack::Item
private

Definition at line 74 of file PageStack.h.

Definition at line 57 of file PageStack.h.

typedef uint32_t Ipc::Mem::PageStack::Value

Definition at line 30 of file PageStack.h.

Constructor & Destructor Documentation

Ipc::Mem::PageStack::PageStack ( const uint32_t  aPoolId,
const unsigned int  aCapacity,
const size_t  aPageSize 
)

Definition at line 21 of file PageStack.cc.

References i, theItems, and theSize.

Member Function Documentation

unsigned int Ipc::Mem::PageStack::capacity ( ) const
inline

Definition at line 34 of file PageStack.h.

References theCapacity.

Offset Ipc::Mem::PageStack::next ( const Offset  idx) const
inlineprivate

Definition at line 60 of file PageStack.h.

References theCapacity.

bool Ipc::Mem::PageStack::pageIdIsValid ( const PageId page) const

Definition at line 110 of file PageStack.cc.

References Ipc::Mem::PageId::number, Ipc::Mem::PageId::pool, and Writable.

size_t Ipc::Mem::PageStack::pageSize ( ) const
inline

Definition at line 35 of file PageStack.h.

References thePageSize.

bool Ipc::Mem::PageStack::pop ( PageId page)
Offset Ipc::Mem::PageStack::prev ( const Offset  idx) const
inlineprivate

Definition at line 61 of file PageStack.h.

References theCapacity.

void Ipc::Mem::PageStack::push ( PageId page)
size_t Ipc::Mem::PageStack::SharedMemorySize ( const uint32_t  aPoolId,
const unsigned int  capacity,
const size_t  pageSize 
)
static

Definition at line 123 of file PageStack.cc.

References Ipc::Mem::PageId::maxPurpose.

size_t Ipc::Mem::PageStack::sharedMemorySize ( ) const

Definition at line 117 of file PageStack.cc.

unsigned int Ipc::Mem::PageStack::size ( ) const
inline

Definition at line 37 of file PageStack.h.

References max(), and theSize.

size_t Ipc::Mem::PageStack::StackSize ( const unsigned int  capacity)
static

shared memory size required only by PageStack, excluding shared counters and page data

Definition at line 131 of file PageStack.cc.

size_t Ipc::Mem::PageStack::stackSize ( ) const

Definition at line 137 of file PageStack.cc.

Member Data Documentation

const Offset Ipc::Mem::PageStack::theCapacity
private

Definition at line 64 of file PageStack.h.

Referenced by capacity(), next(), and prev().

std::atomic<Offset> Ipc::Mem::PageStack::theFirstWritable
private

Definition at line 72 of file PageStack.h.

Ipc::Mem::FlexibleArray<Item> Ipc::Mem::PageStack::theItems
private

Definition at line 75 of file PageStack.h.

Referenced by PageStack().

std::atomic<Offset> Ipc::Mem::PageStack::theLastReadable
private

Definition at line 70 of file PageStack.h.

const size_t Ipc::Mem::PageStack::thePageSize
private

page size, used to calculate shared memory size

Definition at line 65 of file PageStack.h.

Referenced by pageSize().

const uint32_t Ipc::Mem::PageStack::thePoolId
private

Definition at line 63 of file PageStack.h.

std::atomic<Offset> Ipc::Mem::PageStack::theSize
private

Definition at line 67 of file PageStack.h.

Referenced by PageStack(), and size().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors