Browse Source

Some refactoring

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
e3f8dde1b5

+ 1 - 1
AnKi/Util.h

@@ -21,7 +21,7 @@
 #include <AnKi/Util/HighRezTimer.h>
 #include <AnKi/Util/HighRezTimer.h>
 #include <AnKi/Util/List.h>
 #include <AnKi/Util/List.h>
 #include <AnKi/Util/Logger.h>
 #include <AnKi/Util/Logger.h>
-#include <AnKi/Util/Memory.h>
+#include <AnKi/Util/CpuMemoryPools.h>
 #include <AnKi/Util/Hierarchy.h>
 #include <AnKi/Util/Hierarchy.h>
 #include <AnKi/Util/Ptr.h>
 #include <AnKi/Util/Ptr.h>
 #include <AnKi/Util/Singleton.h>
 #include <AnKi/Util/Singleton.h>

+ 1 - 1
AnKi/Util/Allocator.h

@@ -6,7 +6,7 @@
 #pragma once
 #pragma once
 
 
 #include <AnKi/Util/Assert.h>
 #include <AnKi/Util/Assert.h>
-#include <AnKi/Util/Memory.h>
+#include <AnKi/Util/CpuMemoryPools.h>
 #include <AnKi/Util/Logger.h>
 #include <AnKi/Util/Logger.h>
 #include <AnKi/Util/Forward.h>
 #include <AnKi/Util/Forward.h>
 #include <cstddef> // For ptrdiff_t
 #include <cstddef> // For ptrdiff_t

+ 1 - 1
AnKi/Util/CMakeLists.txt

@@ -3,7 +3,7 @@ set(sources
 	Functions.cpp
 	Functions.cpp
 	File.cpp
 	File.cpp
 	Filesystem.cpp
 	Filesystem.cpp
-	Memory.cpp
+	CpuMemoryPools.cpp
 	System.cpp
 	System.cpp
 	HighRezTimer.cpp
 	HighRezTimer.cpp
 	ThreadPool.cpp
 	ThreadPool.cpp

+ 5 - 5
AnKi/Util/Memory.cpp → AnKi/Util/CpuMemoryPools.cpp

@@ -3,7 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-#include <AnKi/Util/Memory.h>
+#include <AnKi/Util/CpuMemoryPools.h>
 #include <AnKi/Util/Functions.h>
 #include <AnKi/Util/Functions.h>
 #include <AnKi/Util/Assert.h>
 #include <AnKi/Util/Assert.h>
 #include <AnKi/Util/Thread.h>
 #include <AnKi/Util/Thread.h>
@@ -140,7 +140,7 @@ void* allocAligned([[maybe_unused]] void* userData, void* ptr, PtrSize size, Ptr
 	return out;
 	return out;
 }
 }
 
 
-BaseMemoryPool::BaseMemoryPool(Type type, AllocAlignedCallback allocCb, void* allocCbUserData, const char* name)
+BaseMemoryPool::BaseMemoryPool(Type type, AllocAlignedCallback allocCb, void* allocCbUserData, const Char* name)
 	: m_allocCb(allocCb)
 	: m_allocCb(allocCb)
 	, m_allocCbUserData(allocCbUserData)
 	, m_allocCbUserData(allocCbUserData)
 	, m_type(type)
 	, m_type(type)
@@ -160,7 +160,7 @@ BaseMemoryPool::~BaseMemoryPool()
 	ANKI_ASSERT(m_refcount.load() == 0 && "Refcount should be zero");
 	ANKI_ASSERT(m_refcount.load() == 0 && "Refcount should be zero");
 }
 }
 
 
-HeapMemoryPool::HeapMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserDataconst, const char* name)
+HeapMemoryPool::HeapMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserDataconst, const Char* name)
 	: BaseMemoryPool(Type::kHeap, allocCb, allocCbUserDataconst, name)
 	: BaseMemoryPool(Type::kHeap, allocCb, allocCbUserDataconst, name)
 {
 {
 #if ANKI_MEM_EXTRA_CHECKS
 #if ANKI_MEM_EXTRA_CHECKS
@@ -267,7 +267,7 @@ void StackMemoryPool::StackAllocatorBuilderInterface::recycleChunk(Chunk& chunk)
 
 
 StackMemoryPool::StackMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
 StackMemoryPool::StackMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
 								 F64 nextChunkScale, PtrSize nextChunkBias, Bool ignoreDeallocationErrors,
 								 F64 nextChunkScale, PtrSize nextChunkBias, Bool ignoreDeallocationErrors,
-								 U32 alignmentBytes, const char* name)
+								 U32 alignmentBytes, const Char* name)
 	: BaseMemoryPool(Type::kStack, allocCb, allocCbUserData, name)
 	: BaseMemoryPool(Type::kStack, allocCb, allocCbUserData, name)
 {
 {
 	ANKI_ASSERT(initialChunkSize > 0);
 	ANKI_ASSERT(initialChunkSize > 0);
@@ -321,7 +321,7 @@ void StackMemoryPool::reset()
 }
 }
 
 
 ChainMemoryPool::ChainMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
 ChainMemoryPool::ChainMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
-								 F32 nextChunkScale, PtrSize nextChunkBias, PtrSize alignmentBytes, const char* name)
+								 F32 nextChunkScale, PtrSize nextChunkBias, PtrSize alignmentBytes, const Char* name)
 	: BaseMemoryPool(Type::kChain, allocCb, allocCbUserData, name)
 	: BaseMemoryPool(Type::kChain, allocCb, allocCbUserData, name)
 {
 {
 	ANKI_ASSERT(initialChunkSize > 0);
 	ANKI_ASSERT(initialChunkSize > 0);

+ 5 - 5
AnKi/Util/Memory.h → AnKi/Util/CpuMemoryPools.h

@@ -100,7 +100,7 @@ public:
 	}
 	}
 
 
 	/// Get the name of the pool.
 	/// Get the name of the pool.
-	const char* getName() const
+	const Char* getName() const
 	{
 	{
 		return (m_name) ? m_name : "Unamed";
 		return (m_name) ? m_name : "Unamed";
 	}
 	}
@@ -125,7 +125,7 @@ protected:
 	Atomic<U32> m_allocationCount = {0};
 	Atomic<U32> m_allocationCount = {0};
 
 
 	/// Construct it.
 	/// Construct it.
-	BaseMemoryPool(Type type, AllocAlignedCallback allocCb, void* allocCbUserData, const char* name);
+	BaseMemoryPool(Type type, AllocAlignedCallback allocCb, void* allocCbUserData, const Char* name);
 
 
 private:
 private:
 	/// Refcount.
 	/// Refcount.
@@ -147,7 +147,7 @@ public:
 	/// @param allocCb The allocation function callback.
 	/// @param allocCb The allocation function callback.
 	/// @param allocCbUserData The user data to pass to the allocation function.
 	/// @param allocCbUserData The user data to pass to the allocation function.
 	/// @param name An optional name.
 	/// @param name An optional name.
-	HeapMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserDataconst, const char* name = nullptr);
+	HeapMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserDataconst, const Char* name = nullptr);
 
 
 	/// Destroy
 	/// Destroy
 	~HeapMemoryPool();
 	~HeapMemoryPool();
@@ -187,7 +187,7 @@ public:
 	/// @param name An optional name.
 	/// @param name An optional name.
 	StackMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
 	StackMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
 					F64 nextChunkScale = 2.0, PtrSize nextChunkBias = 0, Bool ignoreDeallocationErrors = true,
 					F64 nextChunkScale = 2.0, PtrSize nextChunkBias = 0, Bool ignoreDeallocationErrors = true,
-					U32 alignmentBytes = ANKI_SAFE_ALIGNMENT, const char* name = nullptr);
+					U32 alignmentBytes = ANKI_SAFE_ALIGNMENT, const Char* name = nullptr);
 
 
 	/// Destroy
 	/// Destroy
 	~StackMemoryPool();
 	~StackMemoryPool();
@@ -312,7 +312,7 @@ public:
 	/// @param name An optional name.
 	/// @param name An optional name.
 	ChainMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
 	ChainMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
 					F32 nextChunkScale = 2.0, PtrSize nextChunkBias = 0, PtrSize alignmentBytes = ANKI_SAFE_ALIGNMENT,
 					F32 nextChunkScale = 2.0, PtrSize nextChunkBias = 0, PtrSize alignmentBytes = ANKI_SAFE_ALIGNMENT,
-					const char* name = nullptr);
+					const Char* name = nullptr);
 
 
 	/// Destroy
 	/// Destroy
 	~ChainMemoryPool();
 	~ChainMemoryPool();

+ 1 - 1
Tests/Util/Memory.cpp

@@ -5,7 +5,7 @@
 
 
 #include <Tests/Framework/Framework.h>
 #include <Tests/Framework/Framework.h>
 #include <Tests/Util/Foo.h>
 #include <Tests/Util/Foo.h>
-#include <AnKi/Util/Memory.h>
+#include <AnKi/Util/CpuMemoryPools.h>
 #include <AnKi/Util/ThreadPool.h>
 #include <AnKi/Util/ThreadPool.h>
 #include <type_traits>
 #include <type_traits>
 #include <cstring>
 #include <cstring>