StoreEntry *e = new StoreEntry();
e->createMemObject();
- anchorEntry(*e, index, *anchor);
+ e->mem_obj->xitTable.open(index, Store::ioReading);
// keep read lock to receive updates from others
return e;
// set ASAP in hope to unlock the slot if something throws
// and to provide index to such methods as hasWriter()
- auto &xitTable = e.mem_obj->xitTable;
- xitTable.index = index;
- xitTable.io = Store::ioWriting;
+ e.mem_obj->xitTable.open(index, Store::ioWriting);
- anchor->set(e, key);
+ anchor->setKey(key);
// allow reading and receive remote DELETE events, but do not switch to
// the reading lock because transientReaders() callers want true readers
map->startAppending(index);
Transients::addReaderEntry(StoreEntry &e, const cache_key *key)
{
sfileno index = 0;
- const auto anchor = map->openOrCreateForReading(key, index, e);
+ const auto anchor = map->openOrCreateForReading(key, index);
if (!anchor)
throw TextException("reader collision", Here());
- anchorEntry(e, index, *anchor);
+ e.mem_obj->xitTable.open(index, Store::ioReading);
// keep the entry locked (for reading) to receive remote DELETE events
}
-/// fills (recently created) StoreEntry with information currently in Transients
-void
-Transients::anchorEntry(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnchor &anchor)
-{
- // set ASAP in hope to unlock the slot if something throws
- // and to provide index to such methods as hasWriter()
- auto &xitTable = e.mem_obj->xitTable;
- xitTable.index = index;
- xitTable.io = Store::ioReading;
-
- anchor.exportInto(e);
-}
-
bool
Transients::hasWriter(const StoreEntry &e)
{
map->closeForReadingAndFreeIdle(xitTable.index);
}
locals->at(xitTable.index) = nullptr;
- xitTable.index = -1;
- xitTable.io = Store::ioDone;
+ xitTable.close();
}
}
void addEntry(StoreEntry*, const cache_key *, const Store::IoStatus);
void addWriterEntry(StoreEntry &, const cache_key *);
void addReaderEntry(StoreEntry &, const cache_key *);
- void anchorEntry(StoreEntry &, const sfileno, const Ipc::StoreMapAnchor &);
// Ipc::StoreMapCleaner API
void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override;
}
const Ipc::StoreMap::Anchor *
-Ipc::StoreMap::openOrCreateForReading(const cache_key *const key, sfileno &fileno, const StoreEntry &entry)
+Ipc::StoreMap::openOrCreateForReading(const cache_key *const key, sfileno &fileno)
{
debugs(54, 5, "opening/creating entry with key " << storeKeyText(key)
<< " for reading " << path);
// the competing openOrCreateForReading() workers race to create a new entry
idx = fileNoByKey(key);
if (auto anchor = openForWritingAt(idx)) {
- anchor->set(entry, key);
+ anchor->setKey(key);
anchor->lock.switchExclusiveToShared();
// race ended
assert(anchor->complete());
void closeForReadingAndFreeIdle(const sfileno fileno);
/// openForReading() but creates a new entry if there is no old one
- const Anchor *openOrCreateForReading(const cache_key *, sfileno &, const StoreEntry &);
+ const Anchor *openOrCreateForReading(const cache_key *, sfileno &);
/// writeable slice within an entry chain created by openForWriting()
Slice &writeableSlice(const AnchorId anchorId, const SliceId sliceId);