Skip to content

Commit 8ef3e61

Browse files
committed
Making SelfDestroy virtual, remove final for RefCountersImpl.
1 parent d43146d commit 8ef3e61

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

Common/interface/RefCountedObjectImpl.hpp

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,14 @@ class RefCountersImpl : public IReferenceCounters
215215
return m_NumWeakReferences.load();
216216
}
217217

218-
protected:
218+
private:
219219
template <typename AllocatorType, typename ObjectType>
220220
friend class MakeNewRCObj;
221221

222222
RefCountersImpl() noexcept
223223
{
224224
}
225225

226-
private:
227226
class ObjectWrapperBase
228227
{
229228
public:
@@ -449,16 +448,17 @@ class RefCountersImpl : public IReferenceCounters
449448
}
450449
}
451450

452-
protected:
453-
virtual void SelfDestroy() = 0;
451+
virtual void SelfDestroy()
452+
{
453+
delete this;
454+
}
454455

455456
~RefCountersImpl()
456457
{
457458
VERIFY(m_NumStrongReferences.load() == 0 && m_NumWeakReferences.load() == 0,
458459
"There exist outstanding references to the object being destroyed");
459460
}
460461

461-
private:
462462
// No copies/moves
463463
// clang-format off
464464
RefCountersImpl (const RefCountersImpl&) = delete;
@@ -492,21 +492,6 @@ class RefCountersImpl : public IReferenceCounters
492492
std::atomic<ObjectState> m_ObjectState{ObjectState::NotInitialized};
493493
};
494494

495-
class RefCountersAllocationImpl final : public RefCountersImpl
496-
{
497-
private:
498-
template <typename AllocatorType, typename ObjectType>
499-
friend class MakeNewRCObj;
500-
501-
RefCountersAllocationImpl() noexcept
502-
{
503-
}
504-
505-
void SelfDestroy() override final
506-
{
507-
delete this;
508-
}
509-
};
510495

511496
/// Base class for all reference counting objects
512497
template <typename Base>
@@ -669,7 +654,7 @@ class MakeNewRCObj
669654
{
670655
// Constructor of RefCountersImpl class is private and only accessible
671656
// by methods of MakeNewRCObj
672-
pNewRefCounters = new RefCountersAllocationImpl{};
657+
pNewRefCounters = new RefCountersImpl{};
673658
pRefCounters = pNewRefCounters;
674659
}
675660
ObjectType* pObj = nullptr;

Primitives/interface/ReferenceCounters.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ typedef Int32 ReferenceCounterValueType;
4444
class IReferenceCounters
4545
{
4646
public:
47-
virtual ~IReferenceCounters(){};
48-
4947
/// Increments the number of strong references by 1.
5048

5149
/// \return The number of strong references after incrementing the counter.

0 commit comments

Comments
 (0)