summaryrefslogtreecommitdiffstats
path: root/Common/interface
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-10-05 04:51:33 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-10-05 04:51:33 +0000
commitc7391919d2e9d34e7f4fc18e8ffc174a9eabfb5e (patch)
tree1ff73fa0f1ae15b057db84bdeb12de1c5b19b97f /Common/interface
parentAdded ReleaseStaleResources() to IRenderDevice interface + a bunch of minor c... (diff)
downloadDiligentCore-c7391919d2e9d34e7f4fc18e8ffc174a9eabfb5e.tar.gz
DiligentCore-c7391919d2e9d34e7f4fc18e8ffc174a9eabfb5e.zip
Reworked context pool management in D3D12
Diffstat (limited to 'Common/interface')
-rw-r--r--Common/interface/STDAllocator.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/Common/interface/STDAllocator.h b/Common/interface/STDAllocator.h
index cf2290be..10f6769a 100644
--- a/Common/interface/STDAllocator.h
+++ b/Common/interface/STDAllocator.h
@@ -158,17 +158,37 @@ template<class T> using STDAllocatorRawMem = STDAllocator<T, IMemoryAllocator>;
template< class T, typename AllocatorType >
struct STDDeleter
{
- STDDeleter(AllocatorType &Allocator) :
- m_Allocator(Allocator)
+ STDDeleter() noexcept {}
+
+ STDDeleter(AllocatorType& Allocator) noexcept :
+ m_Allocator(&Allocator)
{}
-
- void operator()(T *ptr)
+
+ STDDeleter (const STDDeleter&) = default;
+ STDDeleter& operator = (const STDDeleter&) = default;
+
+ STDDeleter(STDDeleter&& rhs) noexcept :
+ m_Allocator(rhs.m_Allocator)
+ {
+ rhs.m_Allocator = nullptr;
+ }
+
+ STDDeleter& operator = (STDDeleter&& rhs) noexcept
{
+ m_Allocator = rhs.m_Allocator;
+ rhs.m_Allocator = nullptr;
+ return *this;
+ }
+
+ void operator()(T *ptr) noexcept
+ {
+ VERIFY(m_Allocator != nullptr, "The deleter has been moved away or never initialized, and can't be used");
ptr->~T();
- m_Allocator.Free(ptr);
+ m_Allocator->Free(ptr);
}
- AllocatorType &m_Allocator;
+private:
+ AllocatorType* m_Allocator = nullptr;
};
template<class T> using STDDeleterRawMem = STDDeleter<T, IMemoryAllocator>;