Switch from Nz prefix to namespace Nz
What a huge commit Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
@@ -11,39 +11,42 @@
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
class NzMemoryPool
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzMemoryPool(unsigned int blockSize, unsigned int size = 1024, bool canGrow = true);
|
||||
NzMemoryPool(const NzMemoryPool&) = delete;
|
||||
NzMemoryPool(NzMemoryPool&& pool) noexcept;
|
||||
~NzMemoryPool() = default;
|
||||
class MemoryPool
|
||||
{
|
||||
public:
|
||||
MemoryPool(unsigned int blockSize, unsigned int size = 1024, bool canGrow = true);
|
||||
MemoryPool(const MemoryPool&) = delete;
|
||||
MemoryPool(MemoryPool&& pool) noexcept;
|
||||
~MemoryPool() = default;
|
||||
|
||||
void* Allocate(unsigned int size);
|
||||
template<typename T> void Delete(T* ptr);
|
||||
void Free(void* ptr);
|
||||
void* Allocate(unsigned int size);
|
||||
template<typename T> void Delete(T* ptr);
|
||||
void Free(void* ptr);
|
||||
|
||||
unsigned int GetBlockSize() const;
|
||||
unsigned int GetFreeBlocks() const;
|
||||
unsigned int GetSize() const;
|
||||
unsigned int GetBlockSize() const;
|
||||
unsigned int GetFreeBlocks() const;
|
||||
unsigned int GetSize() const;
|
||||
|
||||
template<typename T, typename... Args> T* New(Args&&... args);
|
||||
template<typename T, typename... Args> T* New(Args&&... args);
|
||||
|
||||
NzMemoryPool& operator=(const NzMemoryPool&) = delete;
|
||||
NzMemoryPool& operator=(NzMemoryPool&& pool) noexcept;
|
||||
MemoryPool& operator=(const MemoryPool&) = delete;
|
||||
MemoryPool& operator=(MemoryPool&& pool) noexcept;
|
||||
|
||||
private:
|
||||
NzMemoryPool(NzMemoryPool* pool);
|
||||
private:
|
||||
MemoryPool(MemoryPool* pool);
|
||||
|
||||
std::unique_ptr<void*[]> m_freeList;
|
||||
std::unique_ptr<nzUInt8[]> m_pool;
|
||||
std::unique_ptr<NzMemoryPool> m_next;
|
||||
std::atomic_uint m_freeCount;
|
||||
NzMemoryPool* m_previous;
|
||||
bool m_canGrow;
|
||||
unsigned int m_blockSize;
|
||||
unsigned int m_size;
|
||||
};
|
||||
std::unique_ptr<void*[]> m_freeList;
|
||||
std::unique_ptr<UInt8[]> m_pool;
|
||||
std::unique_ptr<MemoryPool> m_next;
|
||||
std::atomic_uint m_freeCount;
|
||||
MemoryPool* m_previous;
|
||||
bool m_canGrow;
|
||||
unsigned int m_blockSize;
|
||||
unsigned int m_size;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/MemoryPool.inl>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user