Skip to content

Commit 816c860

Browse files
author
devsh
committed
Make the pure virtual IReferenceCounted destructor inline (no more destructors doing cross-DLL calls)
1 parent 5f207dc commit 816c860

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

include/nbl/core/IReferenceCounted.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class NBL_FORCE_EBO IReferenceCounted : public Interface, public AllocationOverr
133133
// Old destructor, but needed virtual for abstractness!
134134
// _NBL_INTERFACE_CHILD_DEFAULT(IReferenceCounted);
135135
//! Destructor, no need to define really, but make it pure virtual to truly prevent instantiation.
136-
NBL_API2 virtual ~IReferenceCounted() = 0;
136+
virtual ~IReferenceCounted() = 0;
137137

138138
//! Sets the debug name of the object.
139139
/** The Debugname may only be set and changed by the object
@@ -155,6 +155,13 @@ class NBL_FORCE_EBO IReferenceCounted : public Interface, public AllocationOverr
155155
static_assert(alignof(std::atomic<uint32_t>) <= _NBL_SIMD_ALIGNMENT/2u, "This compiler has a problem with its atomic int decl!");
156156
static_assert(sizeof(std::atomic<uint32_t>) <= _NBL_SIMD_ALIGNMENT/2u, "This compiler has a problem with its atomic int decl!");
157157
};
158+
159+
// yes pure virt can be inline, just needs a definition outside the class
160+
inline IReferenceCounted::~IReferenceCounted()
161+
{
162+
_NBL_DEBUG_BREAK_IF(ReferenceCounter!=0);
163+
}
164+
158165
static_assert(alignof(IReferenceCounted) == _NBL_SIMD_ALIGNMENT, "This compiler has a problem respecting alignment!");
159166

160167
template<typename T>

src/nbl/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ unset(NABLA_HEADERS_PUBLIC2 ${NBL_TMP_FULL_PATHS})
122122
# <=
123123

124124
set(NBL_CORE_SOURCES
125-
core/IReferenceCounted.cpp
126125
core/alloc/refctd_memory_resource.cpp
127126
core/hash/blake.cpp
128127
)

src/nbl/core/IReferenceCounted.cpp

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)