// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_MEMORYPOOL_HPP #define NAZARA_MEMORYPOOL_HPP #include #include #include template class NzMemoryPool { public: NzMemoryPool(unsigned int size = 1024); ~NzMemoryPool() = default; template T* Allocate(); void* Allocate(unsigned int size); void Free(void* ptr); unsigned int GetFreeBlocks() const; unsigned int GetSize() const; private: NzMemoryPool(NzMemoryPool* pool); std::unique_ptr m_freeList; std::unique_ptr m_pool; std::unique_ptr m_next; std::atomic_uint m_freeCount; NzMemoryPool* m_previous; unsigned int m_size; }; #include #endif // NAZARA_MEMORYPOOL_HPP