tenzr::MemoryPool¶
Process-wide cache of reusable PinnedBuffer allocations, keyed by size.
#include <memory_pool.h>
Public Functions¶
| Name | |
|---|---|
| MemoryPool & | Instance() The process-wide singleton pool. |
| MemoryPool() Mark the pool alive so buffers may safely return to it during teardown. |
|
| ~MemoryPool() Mark the pool dead and release all cached free buffers. |
|
| MemoryPool(const MemoryPool & ) =delete | |
| MemoryPool & | operator=(const MemoryPool & ) =delete |
| std::shared_ptr< PinnedBuffer > | Allocate(size_t size_bytes, bool page_locked =true) Return a buffer of at least size_bytes, reusing a cached one when possible. |
| void | Clear() Release all cached free buffers. |
Public Functions Documentation¶
function Instance¶
The process-wide singleton pool.
Return: Reference to the singleton MemoryPool.
Get the process-wide pinned-buffer pool.
function MemoryPool¶
Mark the pool alive so buffers may safely return to it during teardown.
function ~MemoryPool¶
Mark the pool dead and release all cached free buffers.
function MemoryPool¶
function operator=¶
function Allocate¶
Return a buffer of at least size_bytes, reusing a cached one when possible.
Parameters:
- size_bytes Requested capacity in bytes.
- page_locked Whether a freshly allocated buffer is page-locked.
Return: A buffer that returns itself to the pool on destruction.
Obtain a buffer of size_bytes, reusing a same-sized free buffer when available.
function Clear¶
Release all cached free buffers.
Discard every cached free buffer.