A map of MemMapSlots indexed by their keys, with read/write slot locking. More...

#include <MemMap.h>

Collaboration diagram for Ipc::MemMap:

Classes

class  Shared
 data shared across maps in different processes More...
 

Public Types

typedef MemMapSlot Slot
 
typedef Mem::Owner< SharedOwner
 

Public Member Functions

 MemMap (const char *const aPath)
 
SlotopenForWriting (const cache_key *const key, sfileno &fileno)
 
SlotopenForWritingAt (sfileno fileno, bool overwriteExisting=true)
 
void closeForWriting (const sfileno fileno)
 successfully finish writing the entry More...
 
void switchWritingToReading (const sfileno fileno)
 stop writing the locked entry and start reading it More...
 
const SlotpeekAtReader (const sfileno fileno) const
 only works on locked entries; returns nil unless the slot is readable More...
 
void free (const sfileno fileno)
 mark the slot as waiting to be freed and, if possible, free it More...
 
const SlotopenForReading (const cache_key *const key, sfileno &fileno)
 open slot for reading, increments read level More...
 
const SlotopenForReadingAt (const sfileno fileno)
 open slot for reading, increments read level More...
 
void closeForReading (const sfileno fileno)
 close slot after reading, decrements read level More...
 
bool full () const
 there are no empty slots left More...
 
bool valid (const int n) const
 whether n is a valid slot coordinate More...
 
int entryCount () const
 number of used slots More...
 
int entryLimit () const
 maximum number of slots that can be used More...
 
void updateStats (ReadWriteLockStats &stats) const
 adds approximate current stats to the supplied ones More...
 

Static Public Member Functions

static OwnerInit (const char *const path, const int limit)
 initialize shared memory More...
 

Public Attributes

MemMapCleanercleaner
 

Static Protected Member Functions

static OwnerInit (const char *const path, const int limit, const size_t extrasSize)
 

Protected Attributes

const SBuf path
 cache_dir path, used for logging More...
 
Mem::Pointer< Sharedshared
 

Private Member Functions

int slotIndexByKey (const cache_key *const key) const
 
SlotslotByKey (const cache_key *const key)
 
SlotopenForReading (Slot &s)
 
void abortWriting (const sfileno fileno)
 terminate writing the entry, freeing its slot for others to use More...
 
void freeIfNeeded (Slot &s)
 
void freeLocked (Slot &s, bool keepLocked)
 unconditionally frees the already exclusively locked slot and releases lock More...
 

Detailed Description

Definition at line 56 of file MemMap.h.

Member Typedef Documentation

◆ Owner

Definition at line 77 of file MemMap.h.

◆ Slot

Definition at line 59 of file MemMap.h.

Constructor & Destructor Documentation

◆ MemMap()

Ipc::MemMap::MemMap ( const char *const  aPath)

Definition at line 16 of file MemMap.cc.

References assert, debugs, path, and shared.

Member Function Documentation

◆ abortWriting()

void Ipc::MemMap::abortWriting ( const sfileno  fileno)
private

Definition at line 114 of file MemMap.cc.

References assert, debugs, freeLocked(), path, shared, valid(), and Ipc::MemMapSlot::writing().

◆ closeForReading()

void Ipc::MemMap::closeForReading ( const sfileno  fileno)

◆ closeForWriting()

void Ipc::MemMap::closeForWriting ( const sfileno  fileno)

◆ entryCount()

int Ipc::MemMap::entryCount ( ) const

Definition at line 224 of file MemMap.cc.

References shared.

Referenced by full().

◆ entryLimit()

int Ipc::MemMap::entryLimit ( ) const

Definition at line 218 of file MemMap.cc.

References shared.

Referenced by full(), and valid().

◆ free()

void Ipc::MemMap::free ( const sfileno  fileno)

◆ freeIfNeeded()

void Ipc::MemMap::freeIfNeeded ( Slot s)
private

◆ freeLocked()

◆ full()

bool Ipc::MemMap::full ( ) const

Definition at line 230 of file MemMap.cc.

References entryCount(), and entryLimit().

◆ Init() [1/2]

Ipc::MemMap::Owner * Ipc::MemMap::Init ( const char *const  path,
const int  limit 
)
static

Definition at line 36 of file MemMap.cc.

Referenced by SharedSessionCacheRr::create().

◆ Init() [2/2]

Ipc::MemMap::Owner * Ipc::MemMap::Init ( const char *const  path,
const int  limit,
const size_t  extrasSize 
)
staticprotected

Definition at line 27 of file MemMap.cc.

References assert, debugs, path, and shm_new.

◆ openForReading() [1/2]

const Ipc::MemMap::Slot * Ipc::MemMap::openForReading ( const cache_key *const  key,
sfileno fileno 
)

Definition at line 153 of file MemMap.cc.

References debugs, NULL, openForReadingAt(), path, slotIndexByKey(), and storeKeyText().

Referenced by get_session_cb(), and remove_session_cb().

◆ openForReading() [2/2]

Slot* Ipc::MemMap::openForReading ( Slot s)
private

◆ openForReadingAt()

◆ openForWriting()

Ipc::MemMap::Slot * Ipc::MemMap::openForWriting ( const cache_key *const  key,
sfileno fileno 
)

finds, locks and return a slot for an empty key position, erasing the old entry (if any)

Definition at line 42 of file MemMap.cc.

References debugs, NULL, openForWritingAt(), path, slotIndexByKey(), and storeKeyText().

Referenced by store_session_cb().

◆ openForWritingAt()

Ipc::MemMap::Slot * Ipc::MemMap::openForWritingAt ( sfileno  fileno,
bool  overwriteExisting = true 
)

locks and returns a slot for the empty fileno position; if overwriteExisting is false and the position is not empty, returns nil

Definition at line 57 of file MemMap.cc.

References assert, debugs, Ipc::MemMapSlot::empty(), freeLocked(), Ipc::MemMapSlot::lock, Ipc::ReadWriteLock::lockExclusive(), NULL, path, Ipc::MemMapSlot::reading(), shared, Ipc::ReadWriteLock::unlockExclusive(), Ipc::MemMapSlot::waitingToBeFreed, and Ipc::MemMapSlot::writing().

Referenced by openForWriting().

◆ peekAtReader()

const Ipc::MemMap::Slot * Ipc::MemMap::peekAtReader ( const sfileno  fileno) const

Definition at line 125 of file MemMap.cc.

References assert, NULL, Ipc::MemMapSlot::reading(), shared, valid(), and Ipc::MemMapSlot::writing().

◆ slotByKey()

Ipc::MemMap::Slot & Ipc::MemMap::slotByKey ( const cache_key *const  key)
private

Definition at line 269 of file MemMap.cc.

References shared, and slotIndexByKey().

◆ slotIndexByKey()

int Ipc::MemMap::slotIndexByKey ( const cache_key *const  key) const
private

Definition at line 262 of file MemMap.cc.

References hash_key(), MEMMAP_SLOT_KEY_SIZE, and shared.

Referenced by openForReading(), openForWriting(), and slotByKey().

◆ switchWritingToReading()

void Ipc::MemMap::switchWritingToReading ( const sfileno  fileno)

◆ updateStats()

void Ipc::MemMap::updateStats ( ReadWriteLockStats stats) const

Definition at line 236 of file MemMap.cc.

References i, and shared.

◆ valid()

bool Ipc::MemMap::valid ( const int  n) const

Member Data Documentation

◆ cleaner

MemMapCleaner* Ipc::MemMap::cleaner

The cleaner MemMapCleaner::noteFreeMapSlot method called when a readable entry is freed.

Definition at line 123 of file MemMap.h.

Referenced by freeLocked().

◆ path

◆ shared


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors