Fast aligned bump allocator for multithreaded simulations. More...
#include <pool.hpp>
Public Member Functions | |
PoolAllocator (size_t bytes) | |
Construct a new PoolAllocator with a given size. | |
~PoolAllocator () | |
Destroy the PoolAllocator and free the buffer. | |
template<typename T> | |
T * | allocate (std::size_t align=alignof(T)) |
Allocates memory for type T with specified alignment (default = alignof(T)). | |
void | reset () |
Reset the allocator to reuse buffer (memory). | |
Public Attributes | |
char * | memory |
Raw memory block. | |
std::size_t | capacity |
Total capacity in bytes. | |
std::size_t | offset |
Offset for bump allocation. | |
Fast aligned bump allocator for multithreaded simulations.
Allocates memory from a preallocated buffer using pointer arithmetic. All memory is aligned to 64 bytes to maximize cache and SIMD performance.
|
explicit |
Construct a new PoolAllocator with a given size.
bytes | Number of bytes to preallocate (must be multiple of 64) |
PoolAllocator::~PoolAllocator | ( | ) |
Destroy the PoolAllocator and free the buffer.
T * PoolAllocator::allocate | ( | std::size_t | align = alignof(T) | ) |
Allocates memory for type T with specified alignment (default = alignof(T)).
T | Type of data. |
align | Alignment in bytes (default: alignof(T)). |
Definition at line 168 of file pool.hpp.
void PoolAllocator::reset | ( | ) |
std::size_t PoolAllocator::capacity |
std::size_t PoolAllocator::offset |