Skip to content

Commit eaf1f35

Browse files
committed
headers + test fix
1 parent ed069fa commit eaf1f35

File tree

6 files changed

+8
-35
lines changed

6 files changed

+8
-35
lines changed

cachelib/allocator/MM2Q.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,6 @@ class MM2Q {
402402
// source node already existed.
403403
bool replace(T& oldNode, T& newNode) noexcept;
404404

405-
// Execute provided function under container lock. Function gets
406-
// iterator passed as parameter.
407-
template <typename F>
408-
void withEvictionIterator(F&& f);
409-
410405
// Execute provided function under container lock. Function gets
411406
// iterator passed as parameter.
412407
template <typename F>

cachelib/allocator/MMLru-inl.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,22 +222,16 @@ void MMLru::Container<T, HookPtr>::withEvictionIterator(F&& fun) {
222222
}
223223
}
224224

225-
template <typename T, MMLru::Hook<T> T::*HookPtr>
226-
template <typename F>
227-
void
228-
MMLru::Container<T, HookPtr>::withEvictionIterator(F&& fun) {
229-
lruMutex_->lock_combine([this, &fun]() {
230-
fun(Iterator{LockHolder{}, lru_.rbegin()});
231-
});
232-
}
233-
234225
template <typename T, MMLru::Hook<T> T::*HookPtr>
235226
template <typename F>
236227
void
237228
MMLru::Container<T, HookPtr>::withPromotionIterator(F&& fun) {
238-
lruMutex_->lock_combine([this, &fun]() {
239-
fun(Iterator{LockHolder{}, lru_.begin()});
240-
});
229+
if (config_.useCombinedLockForIterators) {
230+
lruMutex_->lock_combine([this, &fun]() { fun(Iterator{lru_.begin()}); });
231+
} else {
232+
LockHolder lck{*lruMutex_};
233+
fun(Iterator{lru_.begin()});
234+
}
241235
}
242236

243237
template <typename T, MMLru::Hook<T> T::*HookPtr>

cachelib/allocator/MMLru.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,6 @@ class MMLru {
295295
template <typename F>
296296
void withEvictionIterator(F&& f);
297297

298-
// Execute provided function under container lock. Function gets
299-
// iterator passed as parameter.
300-
template <typename F>
301-
void withEvictionIterator(F&& f);
302-
303298
template <typename F>
304299
void withPromotionIterator(F&& f);
305300

cachelib/allocator/MMTinyLFU-inl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,6 @@ void MMTinyLFU::Container<T, HookPtr>::withEvictionIterator(F&& fun) {
220220
fun(Iterator{*this});
221221
}
222222

223-
template <typename T, MMTinyLFU::Hook<T> T::*HookPtr>
224-
template <typename F>
225-
void
226-
MMTinyLFU::Container<T, HookPtr>::withEvictionIterator(F&& fun) {
227-
LockHolder l(lruMutex_);
228-
fun(Iterator{LockHolder{}, *this});
229-
}
230-
231223
template <typename T, MMTinyLFU::Hook<T> T::*HookPtr>
232224
template <typename F>
233225
void

cachelib/allocator/MMTinyLFU.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,6 @@ class MMTinyLFU {
470470
// Returns the eviction age stats. See CacheStats.h for details
471471
EvictionAgeStat getEvictionAgeStat(uint64_t projectedLength) const noexcept;
472472

473-
// Execute provided function under container lock. Function gets
474-
// iterator passed as parameter.
475-
template <typename F>
476-
void withEvictionIterator(F&& f);
477-
478473
// Execute provided function under container lock. Function gets
479474
// iterator passed as parameter.
480475
template <typename F>

cachelib/allocator/tests/ItemTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ TEST(ItemTest, ExpiryTime) {
8282
EXPECT_TRUE(result);
8383
EXPECT_EQ(tenMins, item->getConfiguredTTL());
8484

85+
// So that exclusive bit will be set
86+
item->markAccessible();
8587
// Test that writes fail while the item is moving
8688
item->markExclusive();
8789
result = item->updateExpiryTime(0);

0 commit comments

Comments
 (0)