182 mutable Mutex _mutex;
Dynamic array container wrapping std::vector.
Definition list.h:40
size_t size() const noexcept
Returns the number of elements in the list.
Definition list.h:301
Represents a contiguous region of memory in the pool.
Definition mempool.h:46
size_t size
Size in bytes.
Definition mempool.h:50
bool operator<(const Block &other) const
Orders blocks by address for sorted storage.
Definition mempool.h:54
uintptr_t alignedAddress(size_t align) const
Returns the address aligned to the given alignment.
Definition mempool.h:63
size_t padding(size_t align) const
Returns padding bytes needed to reach the given alignment.
Definition mempool.h:81
bool allocated
true if this block is allocated.
Definition mempool.h:48
size_t alignment
Alignment requirement.
Definition mempool.h:51
uintptr_t alignedAddress() const
Returns the address aligned to this block's alignment.
Definition mempool.h:72
bool follows(const Block &block) const
Returns true if this block immediately follows another.
Definition mempool.h:98
intptr_t address
Starting address of the block.
Definition mempool.h:49
size_t padding() const
Returns padding bytes needed for this block's alignment.
Definition mempool.h:89
Thread-safe memory pool allocator with external metadata.
Definition mempool.h:30
void addRegion(void *startingAddress, size_t size)
Adds a contiguous memory region to the pool.
Definition mempool.h:131
void free(void *ptr)
Frees a previously allocated block back to the pool.
const String & name() const
Returns the name of this memory pool.
Definition mempool.h:137
void dump() const
Dumps the memory map to the logger for debugging.
static bool isValidAlignment(size_t val)
Returns true if the given value is a valid alignment (power of two).
Definition mempool.h:109
BlockSet memoryMap() const
Returns a combined set of all free and allocated blocks.
void setName(const String &val)
Sets the name of this memory pool.
Definition mempool.h:143
MemPool()
Constructs an empty memory pool with a default hex name.
void * allocate(size_t size, size_t alignment=1)
Allocates a block from the pool.
void addRegion(uintptr_t startingAddress, size_t size)
Adds a contiguous memory region to the pool.
Stats stats() const
Returns current pool statistics.
Mutual exclusion lock wrapping std::mutex.
Definition mutex.h:33
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
Statistics about the current state of the memory pool.
Definition mempool.h:35
size_t totalUsed
Total bytes currently allocated.
Definition mempool.h:37
size_t totalFree
Total bytes available for allocation.
Definition mempool.h:36
size_t numFreeBlocks
Number of free block regions.
Definition mempool.h:38
size_t largestFreeBlock
Size in bytes of the largest free block.
Definition mempool.h:40
size_t numAllocatedBlocks
Number of allocated block regions.
Definition mempool.h:39