23template <
typename T,
size_t MinNumDataPerChunk = 64>
37 std::cout <<
ANSI_BBLU <<
"[FlexibleFixedMemoryPool] Destructor" <<
ANSI_RESET << std::endl;
38 for (
size_t i = 0; i <
mChunks.size(); ++i)
46 for (
size_t i = 0; i <
mChunks.size(); ++i)
59 goto ALLLOCATE_NEW_BLOCK;
65 CoreLog(
"[FlexibleFixedMemoryPool] New Chunk Created. Total Chunks: " +
ValToString(
mChunks.size()) +
" Type: " +
typeid(T).name());
78 return reinterpret_cast<T*
>(&block->data);
88 Block* block =
reinterpret_cast<Block*
>(
reinterpret_cast<char*
>(ptr) - offsetof(
Block, data));
109 std::vector< FixedMemoryPool< Block, CHUNK_MEMORY_PAGE_CAPACITY >* >
mChunks;
#define ANSI_BBLU
Definition AnsiColorDefines.hpp:22
#define ANSI_RESET
Definition AnsiColorDefines.hpp:5
#define NODISCARD
Definition AttributeDefines.hpp:17
#define Assert(exp)
Implemented as direct interrupt to avoid dirtying the call stack with assert function when debugging.
Definition MacroDefines.hpp:30
Memory pool that can allocate fixed amount of data.
Definition FixedMemoryPool.hpp:22
A memory pool that can allocate flexible number of data.
Definition FlexibleFixedMemoryPool.hpp:25
@ CHUNK_MEMORY_PAGE_CAPACITY
Definition FlexibleFixedMemoryPool.hpp:108
~FlexibleFixedMemoryPool()
Definition FlexibleFixedMemoryPool.hpp:34
FlexibleFixedMemoryPool()
Definition FlexibleFixedMemoryPool.hpp:27
std::vector< FixedMemoryPool< Block, CHUNK_MEMORY_PAGE_CAPACITY > * > mChunks
Definition FlexibleFixedMemoryPool.hpp:109
void Deallocate(T *ptr)
Definition FlexibleFixedMemoryPool.hpp:81
@ BLOCK_SIZE
Definition FlexibleFixedMemoryPool.hpp:107
size_t mChunkCursor
Index of the first chunk among the chunks with empty space.
Definition FlexibleFixedMemoryPool.hpp:112
T * Allocate()
Definition FlexibleFixedMemoryPool.hpp:52
Definition ControlBlock.hpp:7
@ PAGE_SIZE
Definition GlobalConstants.hpp:7
void CoreLog(const std::string &msg)
Definition Log.hpp:17
void CoreMemoryLeakLog(const std::string &msg)
Definition Log.hpp:19
void CoreMemoryLog(const std::string &msg)
Definition Log.hpp:18
std::string ValToString(const T value)
Definition Log.hpp:23
Definition FlexibleFixedMemoryPool.hpp:101
ALIGNAS(ALIGNOF(T)) char data[sizeof(T)]
size_t chunkIdx
Definition FlexibleFixedMemoryPool.hpp:103