@@ -1289,26 +1289,29 @@ CacheAllocator<CacheTrait>::findEviction(PoolId pid, ClassId cid) {
1289
1289
: toRecycle_;
1290
1290
1291
1291
const bool evictToNvmCache = shouldWriteToNvmCache (*candidate_);
1292
- if (evictToNvmCache)
1293
- token = nvmCache_->createPutToken (candidate_->getKey ());
1292
+ auto token_ = evictToNvmCache
1293
+ ? nvmCache_->createPutToken (candidate_->getKey ())
1294
+ : typename NvmCacheT::PutToken{};
1294
1295
1295
- if (evictToNvmCache && !token .isValid ()) {
1296
+ if (evictToNvmCache && !token_ .isValid ()) {
1296
1297
stats_.evictFailConcurrentFill .inc ();
1297
1298
} else if (candidate_->markForEviction ()) {
1298
1299
XDCHECK (candidate_->isMarkedForEviction ());
1299
1300
// markForEviction to make sure no other thead is evicting the item
1300
1301
// nor holding a handle to that item
1301
1302
toRecycle = toRecycle_;
1302
1303
candidate = candidate_;
1304
+ token = std::move (token_);
1303
1305
1304
1306
// Check if parent changed for chained items - if yes, we cannot
1305
1307
// remove the child from the mmContainer as we will not be evicting
1306
1308
// it. We could abort right here, but we need to cleanup in case
1307
1309
// unmarkForEviction() returns 0 - so just go through normal path.
1308
1310
if (!toRecycle_->isChainedItem () ||
1309
1311
&toRecycle->asChainedItem ().getParentItem (compressor_) ==
1310
- candidate)
1312
+ candidate) {
1311
1313
mmContainer.remove (itr);
1314
+ }
1312
1315
return ;
1313
1316
} else {
1314
1317
if (candidate_->hasChainedItem ()) {
@@ -1324,8 +1327,9 @@ CacheAllocator<CacheTrait>::findEviction(PoolId pid, ClassId cid) {
1324
1327
}
1325
1328
});
1326
1329
1327
- if (!toRecycle)
1330
+ if (!toRecycle) {
1328
1331
continue ;
1332
+ }
1329
1333
1330
1334
XDCHECK (toRecycle);
1331
1335
XDCHECK (candidate);
0 commit comments