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, bool lockForReading=false)
 successfully finish writing the entry 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

Definition at line 77 of file MemMap.h.

Definition at line 59 of file MemMap.h.

Constructor & Destructor Documentation

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

Definition at line 16 of file MemMap.cc.

References assert, debugs, path, and shared.

Member Function Documentation

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

Definition at line 106 of file MemMap.cc.

References assert, debugs, and Ipc::MemMapSlot::writing().

void Ipc::MemMap::closeForReading ( const sfileno  fileno)
void Ipc::MemMap::closeForWriting ( const sfileno  fileno,
bool  lockForReading = false 
)
int Ipc::MemMap::entryCount ( ) const

Definition at line 216 of file MemMap.cc.

int Ipc::MemMap::entryLimit ( ) const

Definition at line 210 of file MemMap.cc.

void Ipc::MemMap::free ( const sfileno  fileno)
void Ipc::MemMap::freeIfNeeded ( Slot s)
private
void Ipc::MemMap::freeLocked ( Slot s,
bool  keepLocked 
)
private
bool Ipc::MemMap::full ( ) const

Definition at line 222 of file MemMap.cc.

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

Definition at line 36 of file MemMap.cc.

References Acl::Init().

Referenced by SharedSessionCacheRr::create().

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, and shm_new.

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

Definition at line 145 of file MemMap.cc.

References debugs, NULL, and storeKeyText().

Referenced by get_session_cb(), and remove_session_cb().

Slot* Ipc::MemMap::openForReading ( Slot s)
private
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, and storeKeyText().

Referenced by store_session_cb().

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(), Ipc::MemMapSlot::lock, Ipc::ReadWriteLock::lockExclusive(), NULL, Ipc::MemMapSlot::reading(), Ipc::ReadWriteLock::unlockExclusive(), Ipc::MemMapSlot::waitingToBeFreed, and Ipc::MemMapSlot::writing().

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

Definition at line 117 of file MemMap.cc.

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

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

Definition at line 261 of file MemMap.cc.

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

Definition at line 254 of file MemMap.cc.

References hash_key(), key, and MEMMAP_SLOT_KEY_SIZE.

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

Definition at line 228 of file MemMap.cc.

References i.

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

Definition at line 235 of file MemMap.cc.

Member Data Documentation

MemMapCleaner* Ipc::MemMap::cleaner

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

Definition at line 120 of file MemMap.h.

const SBuf Ipc::MemMap::path
protected

Definition at line 125 of file MemMap.h.

Referenced by MemMap().

Mem::Pointer<Shared> Ipc::MemMap::shared
protected

Definition at line 126 of file MemMap.h.

Referenced by MemMap().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors