Skip to content

Commit c120a53

Browse files
Jiayue Baofacebook-github-bot
authored andcommitted
Remove isWriteHandle() API
Summary: Based on our discussion, this API would be confusing if a reference of ReadHandle is obtained from a WriteHandle. We also don't want to make it virtual because this will increase `sizeof(ReadHandle)` / `sizeof(WriteHandle)` by 8 bytes. Reviewed By: therealgymmy Differential Revision: D43667308 fbshipit-source-id: a77a17113f1a23f84332ebfa7ea6772d7647339c
1 parent f853a42 commit c120a53

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

cachelib/allocator/Handle.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ struct ReadHandleImpl {
242242
return hdl;
243243
}
244244

245-
bool isWriteHandle() const { return false; }
246-
247245
protected:
248246
// accessor. Calling getInternal() on handle with isReady() == false blocks
249247
// the thread until the handle is ready.
@@ -571,8 +569,6 @@ struct WriteHandleImpl : public ReadHandleImpl<T> {
571569
// creating this item handle.
572570
WriteHandleImpl clone() const { return WriteHandleImpl{ReadHandle::clone()}; }
573571

574-
bool isWriteHandle() const { return true; }
575-
576572
// Friends
577573
friend ReadHandle;
578574
// Only CacheAllocator and NvmCache can create non-default constructed handles

cachelib/allocator/tests/BaseAllocatorTest.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -713,35 +713,29 @@ class BaseAllocatorTest : public AllocatorTest<AllocatorT> {
713713
auto handle = alloc.find("key");
714714
ASSERT_NE(handle, nullptr);
715715
ASSERT_TRUE(isConst(handle->getMemory()));
716-
ASSERT_EQ(handle.isWriteHandle(), false);
717716

718717
// read handle clone
719718
auto handle2 = handle.clone();
720719
ASSERT_TRUE(isConst(handle2->getMemory()));
721-
ASSERT_EQ(handle2.isWriteHandle(), false);
722720

723721
// upgrade a read handle to a write handle
724722
auto handle3 = std::move(handle).toWriteHandle();
725723
ASSERT_FALSE(isConst(handle3->getMemory()));
726-
ASSERT_EQ(handle3.isWriteHandle(), true);
727724
}
728725

729726
{
730727
auto handle = alloc.findToWrite("key");
731728
ASSERT_NE(handle, nullptr);
732729
ASSERT_FALSE(isConst(handle->getMemory()));
733-
ASSERT_EQ(handle.isWriteHandle(), true);
734730

735731
// write handle clone
736732
auto handle2 = handle.clone();
737733
ASSERT_FALSE(isConst(handle2->getMemory()));
738-
ASSERT_EQ(handle2.isWriteHandle(), true);
739734

740735
// downgrade a write handle to a read handle
741736
ReadHandle handle3 = handle.clone();
742737
ASSERT_NE(handle3, nullptr);
743738
ASSERT_TRUE(isConst(handle3->getMemory()));
744-
ASSERT_EQ(handle3.isWriteHandle(), false);
745739
}
746740

747741
{
@@ -752,7 +746,7 @@ class BaseAllocatorTest : public AllocatorTest<AllocatorT> {
752746
// This is like doing a "clone" and setting it into wait context
753747
waitContext->set(alloc.find("key"));
754748
auto handle2 = std::move(handle).toWriteHandle();
755-
ASSERT_EQ(handle2.isWriteHandle(), true);
749+
ASSERT_FALSE(isConst(handle2->getMemory()));
756750
}
757751
}
758752

0 commit comments

Comments
 (0)