@@ -37,11 +37,11 @@ CacheAllocator<CacheTrait>::CacheAllocator(Config config)
3737 accessContainer_(std::make_unique<AccessContainer>(
3838 config_.accessConfig,
3939 compressor_,
40- [this ](Item* it) -> ItemHandle { return acquire (it); })),
40+ [this ](Item* it) -> WriteHandle { return acquire (it); })),
4141 chainedItemAccessContainer_(std::make_unique<AccessContainer>(
4242 config_.chainedItemAccessConfig,
4343 compressor_,
44- [this ](Item* it) -> ItemHandle { return acquire (it); })),
44+ [this ](Item* it) -> WriteHandle { return acquire (it); })),
4545 chainedItemLocks_ (config_.chainedItemsLockPower,
4646 std::make_shared<MurmurHash2>()),
4747 cacheCreationTime_{util::getCurrentTimeSec ()},
@@ -75,7 +75,7 @@ CacheAllocator<CacheTrait>::CacheAllocator(SharedMemNewT, Config config)
7575 ShmSegmentOpts(config_.accessConfig.getPageSize()))
7676 .addr,
7777 compressor_,
78- [this](Item* it) -> ItemHandle { return acquire (it); })),
78+ [this](Item* it) -> WriteHandle { return acquire (it); })),
7979 chainedItemAccessContainer_(std::make_unique<AccessContainer>(
8080 config_.chainedItemAccessConfig,
8181 shmManager_
@@ -86,7 +86,7 @@ CacheAllocator<CacheTrait>::CacheAllocator(SharedMemNewT, Config config)
8686 ShmSegmentOpts(config_.accessConfig.getPageSize()))
8787 .addr,
8888 compressor_,
89- [this](Item* it) -> ItemHandle { return acquire (it); })),
89+ [this](Item* it) -> WriteHandle { return acquire (it); })),
9090 chainedItemLocks_(config_.chainedItemsLockPower,
9191 std::make_shared<MurmurHash2>()),
9292 cacheCreationTime_{util::getCurrentTimeSec ()},
@@ -119,13 +119,13 @@ CacheAllocator<CacheTrait>::CacheAllocator(SharedMemAttachT, Config config)
119119 config_.accessConfig,
120120 shmManager_->attachShm(detail::kShmHashTableName ),
121121 compressor_,
122- [this](Item* it) -> ItemHandle { return acquire (it); })),
122+ [this](Item* it) -> WriteHandle { return acquire (it); })),
123123 chainedItemAccessContainer_ (std::make_unique<AccessContainer>(
124124 deserializer_->deserialize<AccessSerializationType>(),
125125 config_.chainedItemAccessConfig,
126126 shmManager_->attachShm (detail::kShmChainedItemHashTableName ),
127127 compressor_,
128- [this](Item* it) -> ItemHandle { return acquire (it); })),
128+ [this](Item* it) -> WriteHandle { return acquire (it); })),
129129 chainedItemLocks_ (config_.chainedItemsLockPower,
130130 std::make_shared<MurmurHash2>()),
131131 cacheCreationTime_{
@@ -871,16 +871,16 @@ RefcountWithFlags::Value CacheAllocator<CacheTrait>::decRef(Item& it) {
871871}
872872
873873template <typename CacheTrait>
874- typename CacheAllocator<CacheTrait>::ItemHandle
874+ typename CacheAllocator<CacheTrait>::WriteHandle
875875CacheAllocator<CacheTrait>::acquire(Item* it) {
876876 if (UNLIKELY (!it)) {
877- return ItemHandle {};
877+ return WriteHandle {};
878878 }
879879
880880 SCOPE_FAIL { stats_.numRefcountOverflow .inc (); };
881881
882882 incRef (*it);
883- return ItemHandle {it, *this };
883+ return WriteHandle {it, *this };
884884}
885885
886886template <typename CacheTrait>
@@ -1069,7 +1069,7 @@ CacheAllocator<CacheTrait>::insertOrReplace(const WriteHandle& handle) {
10691069
10701070template <typename CacheTrait>
10711071bool CacheAllocator<CacheTrait>::moveRegularItem(Item& oldItem,
1072- ItemHandle & newItemHdl) {
1072+ WriteHandle & newItemHdl) {
10731073 XDCHECK (config_.moveCb );
10741074 util::LatencyTracker tracker{stats_.moveRegularLatency_ };
10751075
@@ -1102,7 +1102,7 @@ bool CacheAllocator<CacheTrait>::moveRegularItem(Item& oldItem,
11021102 // there is no point to replace it since it had already been removed
11031103 // or in the process of being removed. If the item is in cache but the
11041104 // refcount is non-zero, it means user could be attempting to remove
1105- // this item through an API such as remove(ItemHandle ). In this case,
1105+ // this item through an API such as remove(itemHandle ). In this case,
11061106 // it is unsafe to replace the old item with a new one, so we should
11071107 // also abort.
11081108 if (!accessContainer_->replaceIf (oldItem, *newItemHdl, itemMovingPredicate)) {
@@ -1322,7 +1322,7 @@ bool CacheAllocator<CacheTrait>::shouldWriteToNvmCacheExclusive(
13221322}
13231323
13241324template <typename CacheTrait>
1325- typename CacheAllocator<CacheTrait>::ItemHandle
1325+ typename CacheAllocator<CacheTrait>::WriteHandle
13261326CacheAllocator<CacheTrait>::advanceIteratorAndTryEvictRegularItem(
13271327 MMContainer& mmContainer, EvictionIterator& itr) {
13281328 // we should flush this to nvmcache if it is not already present in nvmcache
@@ -1337,7 +1337,7 @@ CacheAllocator<CacheTrait>::advanceIteratorAndTryEvictRegularItem(
13371337 if (evictToNvmCache && !token.isValid ()) {
13381338 ++itr;
13391339 stats_.evictFailConcurrentFill .inc ();
1340- return ItemHandle {};
1340+ return WriteHandle {};
13411341 }
13421342
13431343 // If there are other accessors, we should abort. Acquire a handle here since
@@ -1364,7 +1364,7 @@ CacheAllocator<CacheTrait>::advanceIteratorAndTryEvictRegularItem(
13641364 // is set. Iterator was already advance by the remove call above.
13651365 if (evictHandle->isMoving ()) {
13661366 stats_.evictFailMove .inc ();
1367- return ItemHandle {};
1367+ return WriteHandle {};
13681368 }
13691369
13701370 // Invalidate iterator since later on if we are not evicting this
@@ -1388,7 +1388,7 @@ CacheAllocator<CacheTrait>::advanceIteratorAndTryEvictRegularItem(
13881388}
13891389
13901390template <typename CacheTrait>
1391- typename CacheAllocator<CacheTrait>::ItemHandle
1391+ typename CacheAllocator<CacheTrait>::WriteHandle
13921392CacheAllocator<CacheTrait>::advanceIteratorAndTryEvictChainedItem(
13931393 EvictionIterator& itr) {
13941394 XDCHECK (itr->isChainedItem ());
@@ -1410,7 +1410,7 @@ CacheAllocator<CacheTrait>::advanceIteratorAndTryEvictChainedItem(
14101410 // if token is invalid, return. iterator is already advanced.
14111411 if (evictToNvmCache && !token.isValid ()) {
14121412 stats_.evictFailConcurrentFill .inc ();
1413- return ItemHandle {};
1413+ return WriteHandle {};
14141414 }
14151415
14161416 // check if the parent exists in the hashtable and refcount is drained.
@@ -1446,7 +1446,7 @@ CacheAllocator<CacheTrait>::advanceIteratorAndTryEvictChainedItem(
14461446 // here since moving bit is set.
14471447 if (parentHandle->isMoving ()) {
14481448 stats_.evictFailParentMove .inc ();
1449- return ItemHandle {};
1449+ return WriteHandle {};
14501450 }
14511451
14521452 if (evictToNvmCache && shouldWriteToNvmCacheExclusive (*parentHandle)) {
@@ -1695,7 +1695,7 @@ CacheAllocator<CacheTrait>::inspectCache(typename Item::Key key) {
16951695// CacheAllocator. Hence the sprinkling of UNLIKELY/LIKELY to tell the
16961696// compiler which executions we don't want to optimize on.
16971697template <typename CacheTrait>
1698- typename CacheAllocator<CacheTrait>::ItemHandle
1698+ typename CacheAllocator<CacheTrait>::WriteHandle
16991699CacheAllocator<CacheTrait>::findFastInternal(typename Item::Key key,
17001700 AccessMode mode) {
17011701 auto handle = findInternal (key);
@@ -1711,7 +1711,7 @@ CacheAllocator<CacheTrait>::findFastInternal(typename Item::Key key,
17111711}
17121712
17131713template <typename CacheTrait>
1714- typename CacheAllocator<CacheTrait>::ItemHandle
1714+ typename CacheAllocator<CacheTrait>::WriteHandle
17151715CacheAllocator<CacheTrait>::findFastImpl(typename Item::Key key,
17161716 AccessMode mode) {
17171717 auto handle = findFastInternal (key, mode);
@@ -1751,7 +1751,7 @@ CacheAllocator<CacheTrait>::findFastToWrite(typename Item::Key key,
17511751}
17521752
17531753template <typename CacheTrait>
1754- typename CacheAllocator<CacheTrait>::ItemHandle
1754+ typename CacheAllocator<CacheTrait>::WriteHandle
17551755CacheAllocator<CacheTrait>::findImpl(typename Item::Key key, AccessMode mode) {
17561756 auto handle = findFastInternal (key, mode);
17571757
@@ -1765,7 +1765,7 @@ CacheAllocator<CacheTrait>::findImpl(typename Item::Key key, AccessMode mode) {
17651765 eventTracker->record (AllocatorApiEvent::FIND, key,
17661766 AllocatorApiResult::NOT_FOUND);
17671767 }
1768- ItemHandle ret;
1768+ WriteHandle ret;
17691769 ret.markExpired ();
17701770 return ret;
17711771 }
@@ -1920,8 +1920,8 @@ folly::IOBuf CacheAllocator<CacheTrait>::convertToIOBufT(Handle& handle) {
19201920 ConvertChainedItem converter;
19211921
19221922 // based on current refcount and threshold from config
1923- // determine to use a new ItemHandle for each chain items
1924- // or use shared ItemHandle for all chain items
1923+ // determine to use a new Item Handle for each chain items
1924+ // or use shared Item Handle for all chain items
19251925 if (item->getRefCount () > config_.thresholdForConvertingToIOBuf ) {
19261926 auto sharedHdl = std::make_shared<Handle>(std::move (handle));
19271927
@@ -2568,7 +2568,7 @@ CacheAllocator<CacheTrait>::allocateNewItemForOldItem(const Item& oldItem) {
25682568
25692569template <typename CacheTrait>
25702570bool CacheAllocator<CacheTrait>::tryMovingForSlabRelease(
2571- Item& oldItem, ItemHandle & newItemHdl) {
2571+ Item& oldItem, WriteHandle & newItemHdl) {
25722572 // By holding onto a user-level synchronization object, we ensure moving
25732573 // a regular item or chained item is synchronized with any potential
25742574 // user-side mutation.
@@ -2685,12 +2685,12 @@ void CacheAllocator<CacheTrait>::evictForSlabRelease(
26852685}
26862686
26872687template <typename CacheTrait>
2688- typename CacheAllocator<CacheTrait>::ItemHandle
2688+ typename CacheAllocator<CacheTrait>::WriteHandle
26892689CacheAllocator<CacheTrait>::evictNormalItemForSlabRelease(Item& item) {
26902690 XDCHECK (item.isMoving ());
26912691
26922692 if (item.isOnlyMoving ()) {
2693- return ItemHandle {};
2693+ return WriteHandle {};
26942694 }
26952695
26962696 auto predicate = [](const Item& it) { return it.getRefCount () == 0 ; };
@@ -2723,7 +2723,7 @@ CacheAllocator<CacheTrait>::evictNormalItemForSlabRelease(Item& item) {
27232723}
27242724
27252725template <typename CacheTrait>
2726- typename CacheAllocator<CacheTrait>::ItemHandle
2726+ typename CacheAllocator<CacheTrait>::WriteHandle
27272727CacheAllocator<CacheTrait>::evictChainedItemForSlabRelease(ChainedItem& child) {
27282728 XDCHECK (child.isMoving ());
27292729
0 commit comments