|
Squid Web Cache master
|
A map of MemMapSlots indexed by their keys, with read/write slot locking. More...
#include <MemMap.h>
Classes | |
| class | Shared |
| data shared across maps in different processes More... | |
Public Types | |
| typedef MemMapSlot | Slot |
| typedef Mem::Owner< Shared > | Owner |
Public Member Functions | |
| MemMap (const char *const aPath) | |
| Slot * | openForWriting (const cache_key *const key, sfileno &fileno) |
| Slot * | openForWritingAt (sfileno fileno, bool overwriteExisting=true) |
| void | closeForWriting (const sfileno fileno) |
| successfully finish writing the entry | |
| void | switchWritingToReading (const sfileno fileno) |
| stop writing the locked entry and start reading it | |
| const Slot * | peekAtReader (const sfileno fileno) const |
| only works on locked entries; returns nil unless the slot is readable | |
| void | free (const sfileno fileno) |
| mark the slot as waiting to be freed and, if possible, free it | |
| const Slot * | openForReading (const cache_key *const key, sfileno &fileno) |
| open slot for reading, increments read level | |
| const Slot * | openForReadingAt (const sfileno fileno) |
| open slot for reading, increments read level | |
| void | closeForReading (const sfileno fileno) |
| close slot after reading, decrements read level | |
| bool | full () const |
| there are no empty slots left | |
| bool | valid (const int n) const |
| whether n is a valid slot coordinate | |
| int | entryCount () const |
| number of used slots | |
| int | entryLimit () const |
| maximum number of slots that can be used | |
| void | updateStats (ReadWriteLockStats &stats) const |
| adds approximate current stats to the supplied ones | |
Static Public Member Functions | |
| static Owner * | Init (const char *const path, const int limit) |
| initialize shared memory | |
Public Attributes | |
| MemMapCleaner * | cleaner |
Static Protected Member Functions | |
| static Owner * | Init (const char *const path, const int limit, const size_t extrasSize) |
Protected Attributes | |
| const SBuf | path |
| cache_dir path, used for logging | |
| Mem::Pointer< Shared > | shared |
Private Member Functions | |
| int | slotIndexByKey (const cache_key *const key) const |
| Slot & | slotByKey (const cache_key *const key) |
| Slot * | openForReading (Slot &s) |
| void | abortWriting (const sfileno fileno) |
| terminate writing the entry, freeing its slot for others to use | |
| void | freeIfNeeded (Slot &s) |
| void | freeLocked (Slot &s, bool keepLocked) |
| unconditionally frees the already exclusively locked slot and releases lock | |
| typedef Mem::Owner<Shared> Ipc::MemMap::Owner |
| typedef MemMapSlot Ipc::MemMap::Slot |
| Ipc::MemMap::MemMap | ( | const char *const | aPath | ) |
|
private |
Definition at line 114 of file MemMap.cc.
References assert, debugs, and Ipc::MemMapSlot::writing().
| void Ipc::MemMap::closeForReading | ( | const sfileno | fileno | ) |
Definition at line 207 of file MemMap.cc.
References assert, debugs, Ipc::MemMapSlot::lock, Ipc::MemMapSlot::reading(), and Ipc::ReadWriteLock::unlockShared().
Referenced by get_session_cb(), and remove_session_cb().
| void Ipc::MemMap::closeForWriting | ( | const sfileno | fileno | ) |
Definition at line 91 of file MemMap.cc.
References assert, debugs, Ipc::MemMapSlot::lock, Ipc::ReadWriteLock::unlockExclusive(), and Ipc::MemMapSlot::writing().
Referenced by store_session_cb().
| void Ipc::MemMap::free | ( | const sfileno | fileno | ) |
Definition at line 138 of file MemMap.cc.
References assert, debugs, Ipc::MemMapSlot::lock, Ipc::ReadWriteLock::lockExclusive(), and Ipc::MemMapSlot::waitingToBeFreed.
Referenced by remove_session_cb().
|
private |
|
private |
Definition at line 276 of file MemMap.cc.
References debugs, Ipc::MemMapSlot::empty(), Ipc::MemMapSlot::key, Ipc::MemMapSlot::lock, Ipc::ReadWriteLock::unlockExclusive(), and Ipc::MemMapSlot::waitingToBeFreed.
|
static |
Definition at line 36 of file MemMap.cc.
Referenced by SharedSessionCacheRr::create().
|
staticprotected |
| const Ipc::MemMap::Slot * Ipc::MemMap::openForReading | ( | const cache_key *const | key, |
| sfileno & | fileno | ||
| ) |
Definition at line 153 of file MemMap.cc.
References debugs, and storeKeyText().
Referenced by get_session_cb(), and remove_session_cb().
| const Ipc::MemMap::Slot * Ipc::MemMap::openForReadingAt | ( | const sfileno | fileno | ) |
Definition at line 174 of file MemMap.cc.
References assert, debugs, Ipc::MemMapSlot::empty(), Ipc::MemMapSlot::lock, Ipc::ReadWriteLock::lockShared(), Ipc::ReadWriteLock::unlockShared(), and Ipc::MemMapSlot::waitingToBeFreed.
| 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, 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(), 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 125 of file MemMap.cc.
References assert, Ipc::MemMapSlot::reading(), and Ipc::MemMapSlot::writing().
|
private |
Definition at line 262 of file MemMap.cc.
References hash_key(), and MEMMAP_SLOT_KEY_SIZE.
| void Ipc::MemMap::switchWritingToReading | ( | const sfileno | fileno | ) |
Definition at line 102 of file MemMap.cc.
References assert, debugs, Ipc::MemMapSlot::lock, Ipc::ReadWriteLock::switchExclusiveToShared(), and Ipc::MemMapSlot::writing().
| void Ipc::MemMap::updateStats | ( | ReadWriteLockStats & | stats | ) | const |
| MemMapCleaner* Ipc::MemMap::cleaner |
The cleaner MemMapCleaner::noteFreeMapSlot method called when a readable entry is freed.
|
protected |
|
protected |