9 #ifndef CPPCOMMON_MEMORY_ALLOCATOR_POOL_H
10 #define CPPCOMMON_MEMORY_ALLOCATOR_POOL_H
31 template <
class TAuxMemoryManager = DefaultMemoryManager>
64 size_t allocated() const noexcept {
return _allocated; }
69 size_t page() const noexcept {
return _page; }
71 size_t pages() const noexcept {
return _max_pages; }
74 size_t max_size() const noexcept {
return _auxiliary.max_size(); }
77 TAuxMemoryManager&
auxiliary() noexcept {
return _auxiliary; }
85 void*
malloc(
size_t size,
size_t alignment =
alignof(std::max_align_t));
91 void free(
void* ptr,
size_t size);
106 void reset(
void* buffer,
size_t capacity);
137 TAuxMemoryManager& _auxiliary;
147 FreeBlock* _free_block;
150 size_t AlignAdjustment(
const void* address,
size_t alignment);
152 size_t AlignAdjustment(
const void* address,
size_t alignment,
size_t header);
155 Page* AllocateMemoryPool(
size_t capacity, Page* prev);
157 void ClearMemoryPool();
161 template <
typename T,
class TAuxMemoryManager = DefaultMemoryManager,
bool nothrow = false>
Memory allocator definition.
Memory pool allocator inline implementation.
Memory pool manager class.
PoolMemoryManager & operator=(PoolMemoryManager &&)=delete
size_t pages() const noexcept
Max pages size.
void reset()
Reset the memory manager.
PoolMemoryManager(TAuxMemoryManager &auxiliary)
Initialize memory pool manager with an auxiliary memory manager.
size_t allocated() const noexcept
Allocated memory in bytes.
void * malloc(size_t size, size_t alignment=alignof(std::max_align_t))
Allocate a new memory block of the given size.
PoolMemoryManager(PoolMemoryManager &&)=delete
void clear()
Clear memory pool.
PoolMemoryManager & operator=(const PoolMemoryManager &)=delete
size_t max_size() const noexcept
Maximum memory block size, that could be allocated by the memory manager.
size_t page() const noexcept
Page size in bytes.
size_t allocations() const noexcept
Count of active memory allocations.
TAuxMemoryManager & auxiliary() noexcept
Auxiliary memory manager.
PoolMemoryManager(const PoolMemoryManager &)=delete
void free(void *ptr, size_t size)
Free the previously allocated memory block.
C++ Common project definitions.