7 #ifndef NAZARA_MEMORYPOOL_HPP 8 #define NAZARA_MEMORYPOOL_HPP 10 #include <Nazara/Prerequesites.hpp> 19 MemoryPool(
unsigned int blockSize,
unsigned int size = 1024,
bool canGrow =
true);
26 template<
typename T>
void Delete(T* ptr);
32 inline unsigned int GetSize()
const;
34 template<
typename T,
typename... Args> T*
New(Args&&... args);
42 std::unique_ptr<void* []> m_freeList;
43 std::unique_ptr<UInt8[]> m_pool;
44 std::unique_ptr<MemoryPool> m_next;
45 std::atomic_uint m_freeCount;
48 unsigned int m_blockSize;
53 #include <Nazara/Core/MemoryPool.inl> 55 #endif // NAZARA_MEMORYPOOL_HPP TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Core class that represents a memory pool.
Definition: MemoryPool.hpp:16
unsigned int GetSize() const
Gets the pool size.
Definition: MemoryPool.inl:176
unsigned int GetFreeBlocks() const
Gets the number of free blocks.
Definition: MemoryPool.inl:166
void * Allocate(unsigned int size)
Allocates enough memory for the size and returns a pointer to it.
Definition: MemoryPool.inl:74
MemoryPool(unsigned int blockSize, unsigned int size=1024, bool canGrow=true)
Constructs a MemoryPool object.
Definition: MemoryPool.inl:27
void Free(void *ptr)
Frees the memory represented by the poiner.
Definition: MemoryPool.inl:118
void Delete(T *ptr)
Deletes the memory represented by the poiner.
Definition: MemoryPool.inl:100
unsigned int GetBlockSize() const
Gets the block size.
Definition: MemoryPool.inl:156
T * New(Args &&... args)
Creates a new value of type T with arguments.
Definition: MemoryPool.inl:191